uql-orm 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +521 -0
- package/LICENSE.md +22 -0
- package/README.md +560 -0
- package/dist/browser/cc-BEf4wTUm.js +535 -0
- package/dist/browser/cc-BEf4wTUm.js.map +1 -0
- package/dist/browser/http/bus.d.ts +4 -0
- package/dist/browser/http/bus.d.ts.map +1 -0
- package/dist/browser/http/bus.js +14 -0
- package/dist/browser/http/bus.js.map +1 -0
- package/dist/browser/http/http.d.ts +7 -0
- package/dist/browser/http/http.d.ts.map +1 -0
- package/dist/browser/http/http.js +45 -0
- package/dist/browser/http/http.js.map +1 -0
- package/dist/browser/http/index.d.ts +3 -0
- package/dist/browser/http/index.d.ts.map +1 -0
- package/dist/browser/http/index.js +3 -0
- package/dist/browser/http/index.js.map +1 -0
- package/dist/browser/index.d.ts +5 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +5 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/options.d.ts +5 -0
- package/dist/browser/options.d.ts.map +1 -0
- package/dist/browser/options.js +14 -0
- package/dist/browser/options.js.map +1 -0
- package/dist/browser/querier/httpQuerier.d.ts +20 -0
- package/dist/browser/querier/httpQuerier.d.ts.map +1 -0
- package/dist/browser/querier/httpQuerier.js +68 -0
- package/dist/browser/querier/httpQuerier.js.map +1 -0
- package/dist/browser/querier/index.d.ts +3 -0
- package/dist/browser/querier/index.d.ts.map +1 -0
- package/dist/browser/querier/index.js +3 -0
- package/dist/browser/querier/index.js.map +1 -0
- package/dist/browser/querier/querier.util.d.ts +3 -0
- package/dist/browser/querier/querier.util.d.ts.map +1 -0
- package/dist/browser/querier/querier.util.js +17 -0
- package/dist/browser/querier/querier.util.js.map +1 -0
- package/dist/browser/type/clientQuerier.d.ts +24 -0
- package/dist/browser/type/clientQuerier.d.ts.map +1 -0
- package/dist/browser/type/clientQuerier.js +2 -0
- package/dist/browser/type/clientQuerier.js.map +1 -0
- package/dist/browser/type/clientQuerierPool.d.ts +5 -0
- package/dist/browser/type/clientQuerierPool.d.ts.map +1 -0
- package/dist/browser/type/clientQuerierPool.js +2 -0
- package/dist/browser/type/clientQuerierPool.js.map +1 -0
- package/dist/browser/type/index.d.ts +4 -0
- package/dist/browser/type/index.d.ts.map +1 -0
- package/dist/browser/type/index.js +4 -0
- package/dist/browser/type/index.js.map +1 -0
- package/dist/browser/type/request.d.ts +29 -0
- package/dist/browser/type/request.d.ts.map +1 -0
- package/dist/browser/type/request.js +2 -0
- package/dist/browser/type/request.js.map +1 -0
- package/dist/browser/uql-browser.min.js +4818 -0
- package/dist/browser/uql-browser.min.js.map +1 -0
- package/dist/d1/d1Querier.d.ts +45 -0
- package/dist/d1/d1Querier.d.ts.map +1 -0
- package/dist/d1/d1Querier.js +31 -0
- package/dist/d1/d1Querier.js.map +1 -0
- package/dist/d1/d1QuerierPool.d.ts +10 -0
- package/dist/d1/d1QuerierPool.d.ts.map +1 -0
- package/dist/d1/d1QuerierPool.js +16 -0
- package/dist/d1/d1QuerierPool.js.map +1 -0
- package/dist/d1/index.d.ts +3 -0
- package/dist/d1/index.d.ts.map +1 -0
- package/dist/d1/index.js +3 -0
- package/dist/d1/index.js.map +1 -0
- package/dist/dialect/abstractDialect.d.ts +22 -0
- package/dist/dialect/abstractDialect.d.ts.map +1 -0
- package/dist/dialect/abstractDialect.js +37 -0
- package/dist/dialect/abstractDialect.js.map +1 -0
- package/dist/dialect/abstractSqlDialect.d.ts +140 -0
- package/dist/dialect/abstractSqlDialect.d.ts.map +1 -0
- package/dist/dialect/abstractSqlDialect.js +957 -0
- package/dist/dialect/abstractSqlDialect.js.map +1 -0
- package/dist/dialect/dialectConfig.d.ts +23 -0
- package/dist/dialect/dialectConfig.d.ts.map +1 -0
- package/dist/dialect/dialectConfig.js +96 -0
- package/dist/dialect/dialectConfig.js.map +1 -0
- package/dist/dialect/index.d.ts +5 -0
- package/dist/dialect/index.d.ts.map +1 -0
- package/dist/dialect/index.js +5 -0
- package/dist/dialect/index.js.map +1 -0
- package/dist/dialect/queryContext.d.ts +49 -0
- package/dist/dialect/queryContext.d.ts.map +1 -0
- package/dist/dialect/queryContext.js +65 -0
- package/dist/dialect/queryContext.js.map +1 -0
- package/dist/entity/decorator/definition.d.ts +11 -0
- package/dist/entity/decorator/definition.d.ts.map +1 -0
- package/dist/entity/decorator/definition.js +247 -0
- package/dist/entity/decorator/definition.js.map +1 -0
- package/dist/entity/decorator/entity.d.ts +3 -0
- package/dist/entity/decorator/entity.d.ts.map +1 -0
- package/dist/entity/decorator/entity.js +7 -0
- package/dist/entity/decorator/entity.js.map +1 -0
- package/dist/entity/decorator/field.d.ts +3 -0
- package/dist/entity/decorator/field.d.ts.map +1 -0
- package/dist/entity/decorator/field.js +8 -0
- package/dist/entity/decorator/field.js.map +1 -0
- package/dist/entity/decorator/hook.d.ts +8 -0
- package/dist/entity/decorator/hook.d.ts.map +1 -0
- package/dist/entity/decorator/hook.js +15 -0
- package/dist/entity/decorator/hook.js.map +1 -0
- package/dist/entity/decorator/id.d.ts +3 -0
- package/dist/entity/decorator/id.d.ts.map +1 -0
- package/dist/entity/decorator/id.js +8 -0
- package/dist/entity/decorator/id.js.map +1 -0
- package/dist/entity/decorator/index-decorator.d.ts +36 -0
- package/dist/entity/decorator/index-decorator.d.ts.map +1 -0
- package/dist/entity/decorator/index-decorator.js +52 -0
- package/dist/entity/decorator/index-decorator.js.map +1 -0
- package/dist/entity/decorator/index.d.ts +8 -0
- package/dist/entity/decorator/index.d.ts.map +1 -0
- package/dist/entity/decorator/index.js +8 -0
- package/dist/entity/decorator/index.js.map +1 -0
- package/dist/entity/decorator/relation.d.ts +9 -0
- package/dist/entity/decorator/relation.d.ts.map +1 -0
- package/dist/entity/decorator/relation.js +20 -0
- package/dist/entity/decorator/relation.js.map +1 -0
- package/dist/entity/index.d.ts +2 -0
- package/dist/entity/index.d.ts.map +1 -0
- package/dist/entity/index.js +2 -0
- package/dist/entity/index.js.map +1 -0
- package/dist/express/index.d.ts +3 -0
- package/dist/express/index.d.ts.map +1 -0
- package/dist/express/index.js +3 -0
- package/dist/express/index.js.map +1 -0
- package/dist/express/querierMiddleware.d.ts +26 -0
- package/dist/express/querierMiddleware.d.ts.map +1 -0
- package/dist/express/querierMiddleware.js +149 -0
- package/dist/express/querierMiddleware.js.map +1 -0
- package/dist/express/query.util.d.ts +7 -0
- package/dist/express/query.util.d.ts.map +1 -0
- package/dist/express/query.util.js +28 -0
- package/dist/express/query.util.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/libsql/index.d.ts +3 -0
- package/dist/libsql/index.d.ts.map +1 -0
- package/dist/libsql/index.js +3 -0
- package/dist/libsql/index.js.map +1 -0
- package/dist/libsql/libsqlQuerier.d.ts +17 -0
- package/dist/libsql/libsqlQuerier.d.ts.map +1 -0
- package/dist/libsql/libsqlQuerier.js +71 -0
- package/dist/libsql/libsqlQuerier.js.map +1 -0
- package/dist/libsql/libsqlQuerierPool.d.ts +12 -0
- package/dist/libsql/libsqlQuerierPool.d.ts.map +1 -0
- package/dist/libsql/libsqlQuerierPool.js +19 -0
- package/dist/libsql/libsqlQuerierPool.js.map +1 -0
- package/dist/maria/index.d.ts +4 -0
- package/dist/maria/index.d.ts.map +1 -0
- package/dist/maria/index.js +4 -0
- package/dist/maria/index.js.map +1 -0
- package/dist/maria/mariaDialect.d.ts +10 -0
- package/dist/maria/mariaDialect.d.ts.map +1 -0
- package/dist/maria/mariaDialect.js +41 -0
- package/dist/maria/mariaDialect.js.map +1 -0
- package/dist/maria/mariadbQuerier.d.ts +10 -0
- package/dist/maria/mariadbQuerier.d.ts.map +1 -0
- package/dist/maria/mariadbQuerier.js +20 -0
- package/dist/maria/mariadbQuerier.js.map +1 -0
- package/dist/maria/mariadbQuerierPool.d.ts +11 -0
- package/dist/maria/mariadbQuerierPool.d.ts.map +1 -0
- package/dist/maria/mariadbQuerierPool.js +17 -0
- package/dist/maria/mariadbQuerierPool.js.map +1 -0
- package/dist/migrate/bin.d.ts +3 -0
- package/dist/migrate/bin.d.ts.map +1 -0
- package/dist/migrate/bin.js +7 -0
- package/dist/migrate/bin.js.map +1 -0
- package/dist/migrate/builder/columnBuilder.d.ts +79 -0
- package/dist/migrate/builder/columnBuilder.d.ts.map +1 -0
- package/dist/migrate/builder/columnBuilder.js +159 -0
- package/dist/migrate/builder/columnBuilder.js.map +1 -0
- package/dist/migrate/builder/expressions.d.ts +87 -0
- package/dist/migrate/builder/expressions.d.ts.map +1 -0
- package/dist/migrate/builder/expressions.js +150 -0
- package/dist/migrate/builder/expressions.js.map +1 -0
- package/dist/migrate/builder/index.d.ts +6 -0
- package/dist/migrate/builder/index.d.ts.map +1 -0
- package/dist/migrate/builder/index.js +6 -0
- package/dist/migrate/builder/index.js.map +1 -0
- package/dist/migrate/builder/migrationBuilder.d.ts +109 -0
- package/dist/migrate/builder/migrationBuilder.d.ts.map +1 -0
- package/dist/migrate/builder/migrationBuilder.js +463 -0
- package/dist/migrate/builder/migrationBuilder.js.map +1 -0
- package/dist/migrate/builder/tableBuilder.d.ts +51 -0
- package/dist/migrate/builder/tableBuilder.d.ts.map +1 -0
- package/dist/migrate/builder/tableBuilder.js +291 -0
- package/dist/migrate/builder/tableBuilder.js.map +1 -0
- package/dist/migrate/builder/types.d.ts +466 -0
- package/dist/migrate/builder/types.d.ts.map +1 -0
- package/dist/migrate/builder/types.js +8 -0
- package/dist/migrate/builder/types.js.map +1 -0
- package/dist/migrate/cli-config.d.ts +3 -0
- package/dist/migrate/cli-config.d.ts.map +1 -0
- package/dist/migrate/cli-config.js +35 -0
- package/dist/migrate/cli-config.js.map +1 -0
- package/dist/migrate/cli.d.ts +16 -0
- package/dist/migrate/cli.d.ts.map +1 -0
- package/dist/migrate/cli.js +394 -0
- package/dist/migrate/cli.js.map +1 -0
- package/dist/migrate/codegen/entityCodeGenerator.d.ts +137 -0
- package/dist/migrate/codegen/entityCodeGenerator.d.ts.map +1 -0
- package/dist/migrate/codegen/entityCodeGenerator.js +405 -0
- package/dist/migrate/codegen/entityCodeGenerator.js.map +1 -0
- package/dist/migrate/codegen/entityMerger.d.ts +115 -0
- package/dist/migrate/codegen/entityMerger.d.ts.map +1 -0
- package/dist/migrate/codegen/entityMerger.js +294 -0
- package/dist/migrate/codegen/entityMerger.js.map +1 -0
- package/dist/migrate/codegen/index.d.ts +10 -0
- package/dist/migrate/codegen/index.d.ts.map +1 -0
- package/dist/migrate/codegen/index.js +14 -0
- package/dist/migrate/codegen/index.js.map +1 -0
- package/dist/migrate/codegen/migrationCodeGenerator.d.ts +62 -0
- package/dist/migrate/codegen/migrationCodeGenerator.d.ts.map +1 -0
- package/dist/migrate/codegen/migrationCodeGenerator.js +356 -0
- package/dist/migrate/codegen/migrationCodeGenerator.js.map +1 -0
- package/dist/migrate/codegen/smartRelationDetector.d.ts +48 -0
- package/dist/migrate/codegen/smartRelationDetector.d.ts.map +1 -0
- package/dist/migrate/codegen/smartRelationDetector.js +135 -0
- package/dist/migrate/codegen/smartRelationDetector.js.map +1 -0
- package/dist/migrate/drift/driftDetector.d.ts +81 -0
- package/dist/migrate/drift/driftDetector.d.ts.map +1 -0
- package/dist/migrate/drift/driftDetector.js +248 -0
- package/dist/migrate/drift/driftDetector.js.map +1 -0
- package/dist/migrate/drift/index.d.ts +7 -0
- package/dist/migrate/drift/index.d.ts.map +1 -0
- package/dist/migrate/drift/index.js +7 -0
- package/dist/migrate/drift/index.js.map +1 -0
- package/dist/migrate/generator/index.d.ts +3 -0
- package/dist/migrate/generator/index.d.ts.map +1 -0
- package/dist/migrate/generator/index.js +3 -0
- package/dist/migrate/generator/index.js.map +1 -0
- package/dist/migrate/generator/mongoSchemaGenerator.d.ts +39 -0
- package/dist/migrate/generator/mongoSchemaGenerator.d.ts.map +1 -0
- package/dist/migrate/generator/mongoSchemaGenerator.js +183 -0
- package/dist/migrate/generator/mongoSchemaGenerator.js.map +1 -0
- package/dist/migrate/index.d.ts +13 -0
- package/dist/migrate/index.d.ts.map +1 -0
- package/dist/migrate/index.js +20 -0
- package/dist/migrate/index.js.map +1 -0
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts +77 -0
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts.map +1 -0
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js +156 -0
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js.map +1 -0
- package/dist/migrate/introspection/baseSqlIntrospector.d.ts +28 -0
- package/dist/migrate/introspection/baseSqlIntrospector.d.ts.map +1 -0
- package/dist/migrate/introspection/baseSqlIntrospector.js +135 -0
- package/dist/migrate/introspection/baseSqlIntrospector.js.map +1 -0
- package/dist/migrate/introspection/index.d.ts +6 -0
- package/dist/migrate/introspection/index.d.ts.map +1 -0
- package/dist/migrate/introspection/index.js +6 -0
- package/dist/migrate/introspection/index.js.map +1 -0
- package/dist/migrate/introspection/mongoIntrospector.d.ts +15 -0
- package/dist/migrate/introspection/mongoIntrospector.d.ts.map +1 -0
- package/dist/migrate/introspection/mongoIntrospector.js +100 -0
- package/dist/migrate/introspection/mongoIntrospector.js.map +1 -0
- package/dist/migrate/introspection/mysqlIntrospector.d.ts +59 -0
- package/dist/migrate/introspection/mysqlIntrospector.d.ts.map +1 -0
- package/dist/migrate/introspection/mysqlIntrospector.js +175 -0
- package/dist/migrate/introspection/mysqlIntrospector.js.map +1 -0
- package/dist/migrate/introspection/postgresIntrospector.d.ts +55 -0
- package/dist/migrate/introspection/postgresIntrospector.d.ts.map +1 -0
- package/dist/migrate/introspection/postgresIntrospector.js +226 -0
- package/dist/migrate/introspection/postgresIntrospector.js.map +1 -0
- package/dist/migrate/introspection/sqliteIntrospector.d.ts +60 -0
- package/dist/migrate/introspection/sqliteIntrospector.d.ts.map +1 -0
- package/dist/migrate/introspection/sqliteIntrospector.js +180 -0
- package/dist/migrate/introspection/sqliteIntrospector.js.map +1 -0
- package/dist/migrate/migrator.d.ts +176 -0
- package/dist/migrate/migrator.d.ts.map +1 -0
- package/dist/migrate/migrator.js +624 -0
- package/dist/migrate/migrator.js.map +1 -0
- package/dist/migrate/schemaGenerator.d.ts +132 -0
- package/dist/migrate/schemaGenerator.d.ts.map +1 -0
- package/dist/migrate/schemaGenerator.js +628 -0
- package/dist/migrate/schemaGenerator.js.map +1 -0
- package/dist/migrate/storage/databaseStorage.d.ts +25 -0
- package/dist/migrate/storage/databaseStorage.d.ts.map +1 -0
- package/dist/migrate/storage/databaseStorage.js +77 -0
- package/dist/migrate/storage/databaseStorage.js.map +1 -0
- package/dist/migrate/storage/index.d.ts +3 -0
- package/dist/migrate/storage/index.d.ts.map +1 -0
- package/dist/migrate/storage/index.js +3 -0
- package/dist/migrate/storage/index.js.map +1 -0
- package/dist/migrate/storage/jsonStorage.d.ts +16 -0
- package/dist/migrate/storage/jsonStorage.d.ts.map +1 -0
- package/dist/migrate/storage/jsonStorage.js +43 -0
- package/dist/migrate/storage/jsonStorage.js.map +1 -0
- package/dist/migrate/sync/index.d.ts +7 -0
- package/dist/migrate/sync/index.d.ts.map +1 -0
- package/dist/migrate/sync/index.js +7 -0
- package/dist/migrate/sync/index.js.map +1 -0
- package/dist/migrate/sync/schemaSync.d.ts +132 -0
- package/dist/migrate/sync/schemaSync.d.ts.map +1 -0
- package/dist/migrate/sync/schemaSync.js +260 -0
- package/dist/migrate/sync/schemaSync.js.map +1 -0
- package/dist/mongo/index.d.ts +4 -0
- package/dist/mongo/index.d.ts.map +1 -0
- package/dist/mongo/index.js +4 -0
- package/dist/mongo/index.js.map +1 -0
- package/dist/mongo/mongoDialect.d.ts +47 -0
- package/dist/mongo/mongoDialect.d.ts.map +1 -0
- package/dist/mongo/mongoDialect.js +299 -0
- package/dist/mongo/mongoDialect.js.map +1 -0
- package/dist/mongo/mongodbQuerier.d.ts +32 -0
- package/dist/mongo/mongodbQuerier.d.ts.map +1 -0
- package/dist/mongo/mongodbQuerier.js +267 -0
- package/dist/mongo/mongodbQuerier.js.map +1 -0
- package/dist/mongo/mongodbQuerierPool.d.ts +11 -0
- package/dist/mongo/mongodbQuerierPool.d.ts.map +1 -0
- package/dist/mongo/mongodbQuerierPool.js +20 -0
- package/dist/mongo/mongodbQuerierPool.js.map +1 -0
- package/dist/mysql/index.d.ts +4 -0
- package/dist/mysql/index.d.ts.map +1 -0
- package/dist/mysql/index.js +4 -0
- package/dist/mysql/index.js.map +1 -0
- package/dist/mysql/mysql2Querier.d.ts +14 -0
- package/dist/mysql/mysql2Querier.d.ts.map +1 -0
- package/dist/mysql/mysql2Querier.js +25 -0
- package/dist/mysql/mysql2Querier.js.map +1 -0
- package/dist/mysql/mysql2QuerierPool.d.ts +11 -0
- package/dist/mysql/mysql2QuerierPool.d.ts.map +1 -0
- package/dist/mysql/mysql2QuerierPool.js +17 -0
- package/dist/mysql/mysql2QuerierPool.js.map +1 -0
- package/dist/mysql/mysqlDialect.d.ts +19 -0
- package/dist/mysql/mysqlDialect.d.ts.map +1 -0
- package/dist/mysql/mysqlDialect.js +97 -0
- package/dist/mysql/mysqlDialect.js.map +1 -0
- package/dist/namingStrategy/defaultNamingStrategy.d.ts +10 -0
- package/dist/namingStrategy/defaultNamingStrategy.d.ts.map +1 -0
- package/dist/namingStrategy/defaultNamingStrategy.js +15 -0
- package/dist/namingStrategy/defaultNamingStrategy.js.map +1 -0
- package/dist/namingStrategy/index.d.ts +3 -0
- package/dist/namingStrategy/index.d.ts.map +1 -0
- package/dist/namingStrategy/index.js +3 -0
- package/dist/namingStrategy/index.js.map +1 -0
- package/dist/namingStrategy/snakeCaseNamingStrategy.d.ts +9 -0
- package/dist/namingStrategy/snakeCaseNamingStrategy.d.ts.map +1 -0
- package/dist/namingStrategy/snakeCaseNamingStrategy.js +14 -0
- package/dist/namingStrategy/snakeCaseNamingStrategy.js.map +1 -0
- package/dist/neon/index.d.ts +3 -0
- package/dist/neon/index.d.ts.map +1 -0
- package/dist/neon/index.js +3 -0
- package/dist/neon/index.js.map +1 -0
- package/dist/neon/neonQuerier.d.ts +10 -0
- package/dist/neon/neonQuerier.d.ts.map +1 -0
- package/dist/neon/neonQuerier.js +20 -0
- package/dist/neon/neonQuerier.js.map +1 -0
- package/dist/neon/neonQuerierPool.d.ts +11 -0
- package/dist/neon/neonQuerierPool.d.ts.map +1 -0
- package/dist/neon/neonQuerierPool.js +17 -0
- package/dist/neon/neonQuerierPool.js.map +1 -0
- package/dist/options.d.ts +5 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +14 -0
- package/dist/options.js.map +1 -0
- package/dist/postgres/index.d.ts +4 -0
- package/dist/postgres/index.d.ts.map +1 -0
- package/dist/postgres/index.js +4 -0
- package/dist/postgres/index.js.map +1 -0
- package/dist/postgres/pgQuerier.d.ts +10 -0
- package/dist/postgres/pgQuerier.d.ts.map +1 -0
- package/dist/postgres/pgQuerier.js +20 -0
- package/dist/postgres/pgQuerier.js.map +1 -0
- package/dist/postgres/pgQuerierPool.d.ts +11 -0
- package/dist/postgres/pgQuerierPool.d.ts.map +1 -0
- package/dist/postgres/pgQuerierPool.js +17 -0
- package/dist/postgres/pgQuerierPool.js.map +1 -0
- package/dist/postgres/postgresDialect.d.ts +36 -0
- package/dist/postgres/postgresDialect.d.ts.map +1 -0
- package/dist/postgres/postgresDialect.js +201 -0
- package/dist/postgres/postgresDialect.js.map +1 -0
- package/dist/querier/abstractPoolQuerier.d.ts +13 -0
- package/dist/querier/abstractPoolQuerier.d.ts.map +1 -0
- package/dist/querier/abstractPoolQuerier.js +25 -0
- package/dist/querier/abstractPoolQuerier.js.map +1 -0
- package/dist/querier/abstractQuerier.d.ts +109 -0
- package/dist/querier/abstractQuerier.d.ts.map +1 -0
- package/dist/querier/abstractQuerier.js +378 -0
- package/dist/querier/abstractQuerier.js.map +1 -0
- package/dist/querier/abstractQuerierPool.d.ts +23 -0
- package/dist/querier/abstractQuerierPool.d.ts.map +1 -0
- package/dist/querier/abstractQuerierPool.js +28 -0
- package/dist/querier/abstractQuerierPool.js.map +1 -0
- package/dist/querier/abstractSqlQuerier.d.ts +38 -0
- package/dist/querier/abstractSqlQuerier.d.ts.map +1 -0
- package/dist/querier/abstractSqlQuerier.js +169 -0
- package/dist/querier/abstractSqlQuerier.js.map +1 -0
- package/dist/querier/decorator/index.d.ts +5 -0
- package/dist/querier/decorator/index.d.ts.map +1 -0
- package/dist/querier/decorator/index.js +5 -0
- package/dist/querier/decorator/index.js.map +1 -0
- package/dist/querier/decorator/injectQuerier.d.ts +4 -0
- package/dist/querier/decorator/injectQuerier.d.ts.map +1 -0
- package/dist/querier/decorator/injectQuerier.js +33 -0
- package/dist/querier/decorator/injectQuerier.js.map +1 -0
- package/dist/querier/decorator/log.d.ts +7 -0
- package/dist/querier/decorator/log.d.ts.map +1 -0
- package/dist/querier/decorator/log.js +27 -0
- package/dist/querier/decorator/log.js.map +1 -0
- package/dist/querier/decorator/serialized.d.ts +7 -0
- package/dist/querier/decorator/serialized.d.ts.map +1 -0
- package/dist/querier/decorator/serialized.js +14 -0
- package/dist/querier/decorator/serialized.js.map +1 -0
- package/dist/querier/decorator/transactional.d.ts +6 -0
- package/dist/querier/decorator/transactional.d.ts.map +1 -0
- package/dist/querier/decorator/transactional.js +48 -0
- package/dist/querier/decorator/transactional.js.map +1 -0
- package/dist/querier/index.d.ts +5 -0
- package/dist/querier/index.d.ts.map +1 -0
- package/dist/querier/index.js +5 -0
- package/dist/querier/index.js.map +1 -0
- package/dist/schema/canonicalType.d.ts +42 -0
- package/dist/schema/canonicalType.d.ts.map +1 -0
- package/dist/schema/canonicalType.js +524 -0
- package/dist/schema/canonicalType.js.map +1 -0
- package/dist/schema/index.d.ts +28 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +29 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/schemaAST.d.ts +155 -0
- package/dist/schema/schemaAST.d.ts.map +1 -0
- package/dist/schema/schemaAST.js +496 -0
- package/dist/schema/schemaAST.js.map +1 -0
- package/dist/schema/schemaASTBuilder.d.ts +58 -0
- package/dist/schema/schemaASTBuilder.d.ts.map +1 -0
- package/dist/schema/schemaASTBuilder.js +224 -0
- package/dist/schema/schemaASTBuilder.js.map +1 -0
- package/dist/schema/schemaASTDiffer.d.ts +84 -0
- package/dist/schema/schemaASTDiffer.d.ts.map +1 -0
- package/dist/schema/schemaASTDiffer.js +431 -0
- package/dist/schema/schemaASTDiffer.js.map +1 -0
- package/dist/schema/types.d.ts +347 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/types.js +11 -0
- package/dist/schema/types.js.map +1 -0
- package/dist/sqlite/abstractSqliteQuerier.d.ts +6 -0
- package/dist/sqlite/abstractSqliteQuerier.d.ts.map +1 -0
- package/dist/sqlite/abstractSqliteQuerier.js +13 -0
- package/dist/sqlite/abstractSqliteQuerier.js.map +1 -0
- package/dist/sqlite/index.d.ts +4 -0
- package/dist/sqlite/index.d.ts.map +1 -0
- package/dist/sqlite/index.js +4 -0
- package/dist/sqlite/index.js.map +1 -0
- package/dist/sqlite/sqliteDialect.d.ts +42 -0
- package/dist/sqlite/sqliteDialect.d.ts.map +1 -0
- package/dist/sqlite/sqliteDialect.js +129 -0
- package/dist/sqlite/sqliteDialect.js.map +1 -0
- package/dist/sqlite/sqliteQuerier.d.ts +12 -0
- package/dist/sqlite/sqliteQuerier.d.ts.map +1 -0
- package/dist/sqlite/sqliteQuerier.js +25 -0
- package/dist/sqlite/sqliteQuerier.js.map +1 -0
- package/dist/sqlite/sqliteQuerierPool.d.ts +13 -0
- package/dist/sqlite/sqliteQuerierPool.d.ts.map +1 -0
- package/dist/sqlite/sqliteQuerierPool.js +34 -0
- package/dist/sqlite/sqliteQuerierPool.js.map +1 -0
- package/dist/type/config.d.ts +46 -0
- package/dist/type/config.d.ts.map +1 -0
- package/dist/type/config.js +2 -0
- package/dist/type/config.js.map +1 -0
- package/dist/type/entity.d.ts +289 -0
- package/dist/type/entity.d.ts.map +1 -0
- package/dist/type/entity.js +5 -0
- package/dist/type/entity.js.map +1 -0
- package/dist/type/index.d.ts +11 -0
- package/dist/type/index.d.ts.map +1 -0
- package/dist/type/index.js +11 -0
- package/dist/type/index.js.map +1 -0
- package/dist/type/logger.d.ts +61 -0
- package/dist/type/logger.d.ts.map +1 -0
- package/dist/type/logger.js +2 -0
- package/dist/type/logger.js.map +1 -0
- package/dist/type/migration.d.ts +268 -0
- package/dist/type/migration.d.ts.map +1 -0
- package/dist/type/migration.js +2 -0
- package/dist/type/migration.js.map +1 -0
- package/dist/type/namingStrategy.d.ts +18 -0
- package/dist/type/namingStrategy.d.ts.map +1 -0
- package/dist/type/namingStrategy.js +2 -0
- package/dist/type/namingStrategy.js.map +1 -0
- package/dist/type/querier.d.ts +154 -0
- package/dist/type/querier.d.ts.map +1 -0
- package/dist/type/querier.js +11 -0
- package/dist/type/querier.js.map +1 -0
- package/dist/type/querierPool.d.ts +31 -0
- package/dist/type/querierPool.d.ts.map +1 -0
- package/dist/type/querierPool.js +2 -0
- package/dist/type/querierPool.js.map +1 -0
- package/dist/type/query.d.ts +475 -0
- package/dist/type/query.d.ts.map +1 -0
- package/dist/type/query.js +11 -0
- package/dist/type/query.js.map +1 -0
- package/dist/type/universalQuerier.d.ts +120 -0
- package/dist/type/universalQuerier.d.ts.map +1 -0
- package/dist/type/universalQuerier.js +2 -0
- package/dist/type/universalQuerier.js.map +1 -0
- package/dist/type/utility.d.ts +33 -0
- package/dist/type/utility.d.ts.map +1 -0
- package/dist/type/utility.js +2 -0
- package/dist/type/utility.js.map +1 -0
- package/dist/util/dialect.util.d.ts +13 -0
- package/dist/util/dialect.util.d.ts.map +1 -0
- package/dist/util/dialect.util.js +82 -0
- package/dist/util/dialect.util.js.map +1 -0
- package/dist/util/field.util.d.ts +14 -0
- package/dist/util/field.util.d.ts.map +1 -0
- package/dist/util/field.util.js +57 -0
- package/dist/util/field.util.js.map +1 -0
- package/dist/util/hook.util.d.ts +15 -0
- package/dist/util/hook.util.d.ts.map +1 -0
- package/dist/util/hook.util.js +20 -0
- package/dist/util/hook.util.js.map +1 -0
- package/dist/util/index.d.ts +9 -0
- package/dist/util/index.d.ts.map +1 -0
- package/dist/util/index.js +9 -0
- package/dist/util/index.js.map +1 -0
- package/dist/util/logger.d.ts +34 -0
- package/dist/util/logger.d.ts.map +1 -0
- package/dist/util/logger.js +129 -0
- package/dist/util/logger.js.map +1 -0
- package/dist/util/object.util.d.ts +8 -0
- package/dist/util/object.util.d.ts.map +1 -0
- package/dist/util/object.util.js +19 -0
- package/dist/util/object.util.js.map +1 -0
- package/dist/util/raw.d.ts +9 -0
- package/dist/util/raw.d.ts.map +1 -0
- package/dist/util/raw.js +11 -0
- package/dist/util/raw.js.map +1 -0
- package/dist/util/sql.util.d.ts +22 -0
- package/dist/util/sql.util.d.ts.map +1 -0
- package/dist/util/sql.util.js +88 -0
- package/dist/util/sql.util.js.map +1 -0
- package/dist/util/string.util.d.ts +29 -0
- package/dist/util/string.util.d.ts.map +1 -0
- package/dist/util/string.util.js +91 -0
- package/dist/util/string.util.js.map +1 -0
- package/package.json +146 -0
|
@@ -0,0 +1,4818 @@
|
|
|
1
|
+
import { _ as _apply_decs_2203_r } from './cc-BEf4wTUm.js';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { Id, Field, ManyToOne, Entity, OneToOne, OneToMany, ManyToMany } from '../entity/index.js';
|
|
4
|
+
import '../type/index.js';
|
|
5
|
+
import { raw, lowerFirst, upperFirst, getKeys } from '../util/index.js';
|
|
6
|
+
import 'reflect-metadata';
|
|
7
|
+
|
|
8
|
+
var _dec, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, /**
|
|
9
|
+
* auto-generated primary-key (when the `onInsert` property is omitted).
|
|
10
|
+
*/ _init_id, /**
|
|
11
|
+
* foreign-keys are really simple to specify with the `reference` property.
|
|
12
|
+
*/ _init_companyId, /**
|
|
13
|
+
* The `Relation` wrapper type can be used in ESM projects for the relations to
|
|
14
|
+
* avoid circular dependency issues.
|
|
15
|
+
*/ _init_company, _init_creatorId, _init_creator, /**
|
|
16
|
+
* 'onInsert' property can be used to specify a custom mechanism for
|
|
17
|
+
* obtaining the value of a field when inserting:
|
|
18
|
+
*/ _init_createdAt, /**
|
|
19
|
+
* 'onUpdate' property can be used to specify a custom mechanism for
|
|
20
|
+
* obtaining the value of a field when updating:
|
|
21
|
+
*/ _init_updatedAt, _initProto, _dec7, _initClass, _BaseEntity, _dec8, _dec9, _dec10, _init_name, _init_description, _init_kind, _initProto1, _dec11, _initClass1, _BaseEntity1, _dec12, _dec13, /**
|
|
22
|
+
* an entity can specify its own ID Field and still inherit the others
|
|
23
|
+
* columns/relations from its parent entity.
|
|
24
|
+
*/ _init_pk, _init_picture, _initProto2, _dec14, _initClass2, _BaseEntity2, _dec15, _dec16, _dec17, _dec18, _dec19, _init_name1, _init_email, _init_password, /**
|
|
25
|
+
* `mappedBy` property can be a callback or a string (callback is useful for auto-refactoring).
|
|
26
|
+
*/ _init_profile, _init_users, _initProto3, _dec20, _initClass3, _dec21, _dec22, _init_id1, _init_name2, _initProto4, _dec23, _initClass4, _BaseEntity3, _dec24, _dec25, _dec26, _dec27, _init_name3, _init_description1, _init_parentLedgerId, _init_parentLedger, _initProto5, _dec28, _initClass5, _BaseEntity4, _dec29, _dec30, _dec31, /**
|
|
27
|
+
* an entity can override the ID Field and still inherit the others
|
|
28
|
+
* columns/relations from its parent entity.
|
|
29
|
+
* 'onInsert' property can be used to specify a custom mechanism for
|
|
30
|
+
* auto-generating the primary-key's value when inserting.
|
|
31
|
+
*/ _init_pk1, _init_name4, _init_description2, _initProto6, _dec32, _initClass6, _BaseEntity5, _dec33, _dec34, _dec35, _dec36, _dec37, _init_name5, _init_percentage, _init_categoryId, _init_category, _init_description3, _initProto7, _dec38, _initClass7, _BaseEntity6, _dec39, _dec40, _dec41, _init_name6, _init_measureUnits, /**
|
|
32
|
+
* `onDelete` callback allows to specify which field will be used when deleting/querying this entity.
|
|
33
|
+
*/ _init_deletedAt, _initProto8, _dec42, _initClass8, _BaseEntity7, _dec43, _dec44, _dec45, _dec46, _init_name7, _init_categoryId1, _init_category1, _init_deletedAt1, _initProto9, _dec47, _initClass9, _BaseEntity8, _dec48, _dec49, _dec50, _init_name8, _init_address, _init_description4, _initProto10, _dec51, _initClass10, _BaseEntity9, _dec52, _dec53, _dec54, _dec55, _dec56, _dec57, _dec58, _dec59, _dec60, _dec61, _dec62, _dec63, _dec64, _dec65, _dec66, _init_name9, _init_description5, _init_code, _init_buyLedgerAccountId, _init_buyLedgerAccount, _init_saleLedgerAccountId, _init_saleLedgerAccount, _init_taxId, _init_tax, _init_measureUnitId, _init_measureUnit, _init_salePrice, _init_inventoryable, _init_tags, _init_tagsCount, _initProto11, _dec67, _initClass11, _BaseEntity10, _dec68, _dec69, _dec70, _init_name10, _init_items, _init_itemsCount, _initProto12, _dec71, _initClass12, _dec72, _dec73, _dec74, _init_id2, _init_itemId, _init_tagId, _initProto13, _dec75, _initClass13, _BaseEntity11, _dec76, _dec77, _dec78, _init_itemAdjustments, _init_date, _init_description6, _initProto14, _dec79, _initClass14, _BaseEntity12, _dec80, _dec81, _dec82, _dec83, _dec84, _dec85, _dec86, _dec87, _init_itemId1, _init_item, _init_number, _init_buyPrice, _init_storehouseId, _init_storehouse, _init_inventoryAdjustmentId, _init_inventoryAdjustment, _initProto15;
|
|
34
|
+
_dec = Id(), _dec1 = Field({
|
|
35
|
+
references: ()=>_Company
|
|
36
|
+
}), _dec2 = ManyToOne({
|
|
37
|
+
entity: ()=>_Company
|
|
38
|
+
}), _dec3 = Field({
|
|
39
|
+
references: ()=>_User
|
|
40
|
+
}), _dec4 = ManyToOne({
|
|
41
|
+
entity: ()=>_User
|
|
42
|
+
}), _dec5 = Field({
|
|
43
|
+
onInsert: Date.now
|
|
44
|
+
}), _dec6 = Field({
|
|
45
|
+
onUpdate: Date.now
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* an `abstract` class can (optionally) be used as the base "template" for the entities
|
|
49
|
+
* (so common fields' declaration is easily reused).
|
|
50
|
+
*/ class BaseEntity {
|
|
51
|
+
static{
|
|
52
|
+
({ e: [_init_id, _init_companyId, _init_company, _init_creatorId, _init_creator, _init_createdAt, _init_updatedAt, _initProto] } = _apply_decs_2203_r(this, [
|
|
53
|
+
[
|
|
54
|
+
_dec,
|
|
55
|
+
0,
|
|
56
|
+
"id"
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
_dec1,
|
|
60
|
+
0,
|
|
61
|
+
"companyId"
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
_dec2,
|
|
65
|
+
0,
|
|
66
|
+
"company"
|
|
67
|
+
],
|
|
68
|
+
[
|
|
69
|
+
_dec3,
|
|
70
|
+
0,
|
|
71
|
+
"creatorId"
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
_dec4,
|
|
75
|
+
0,
|
|
76
|
+
"creator"
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
_dec5,
|
|
80
|
+
0,
|
|
81
|
+
"createdAt"
|
|
82
|
+
],
|
|
83
|
+
[
|
|
84
|
+
_dec6,
|
|
85
|
+
0,
|
|
86
|
+
"updatedAt"
|
|
87
|
+
]
|
|
88
|
+
], []));
|
|
89
|
+
}
|
|
90
|
+
constructor(){
|
|
91
|
+
this.id = (_initProto(this), _init_id(this));
|
|
92
|
+
this.companyId = _init_companyId(this);
|
|
93
|
+
this.company = _init_company(this);
|
|
94
|
+
this.creatorId = _init_creatorId(this);
|
|
95
|
+
this.creator = _init_creator(this);
|
|
96
|
+
this.createdAt = _init_createdAt(this);
|
|
97
|
+
this.updatedAt = _init_updatedAt(this);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
let _Company;
|
|
101
|
+
_dec7 = Entity(), _dec8 = Field(), _dec9 = Field(), _dec10 = Field({
|
|
102
|
+
type: 'jsonb'
|
|
103
|
+
});
|
|
104
|
+
class Company extends (_BaseEntity = BaseEntity) {
|
|
105
|
+
static{
|
|
106
|
+
({ e: [_init_name, _init_description, _init_kind, _initProto1], c: [_Company, _initClass] } = _apply_decs_2203_r(this, [
|
|
107
|
+
[
|
|
108
|
+
_dec8,
|
|
109
|
+
0,
|
|
110
|
+
"name"
|
|
111
|
+
],
|
|
112
|
+
[
|
|
113
|
+
_dec9,
|
|
114
|
+
0,
|
|
115
|
+
"description"
|
|
116
|
+
],
|
|
117
|
+
[
|
|
118
|
+
_dec10,
|
|
119
|
+
0,
|
|
120
|
+
"kind"
|
|
121
|
+
]
|
|
122
|
+
], [
|
|
123
|
+
_dec7
|
|
124
|
+
], _BaseEntity));
|
|
125
|
+
}
|
|
126
|
+
static{
|
|
127
|
+
_initClass();
|
|
128
|
+
}
|
|
129
|
+
constructor(...args){
|
|
130
|
+
super(...args), this.name = (_initProto1(this), _init_name(this)), this.description = _init_description(this), this.kind = _init_kind(this);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
let _Profile;
|
|
134
|
+
_dec11 = Entity({
|
|
135
|
+
name: 'user_profile'
|
|
136
|
+
}), _dec12 = Id(), _dec13 = Field({
|
|
137
|
+
name: 'image'
|
|
138
|
+
});
|
|
139
|
+
class Profile extends (_BaseEntity1 = BaseEntity) {
|
|
140
|
+
static{
|
|
141
|
+
({ e: [_init_pk, _init_picture, _initProto2], c: [_Profile, _initClass1] } = _apply_decs_2203_r(this, [
|
|
142
|
+
[
|
|
143
|
+
_dec12,
|
|
144
|
+
0,
|
|
145
|
+
"pk"
|
|
146
|
+
],
|
|
147
|
+
[
|
|
148
|
+
_dec13,
|
|
149
|
+
0,
|
|
150
|
+
"picture"
|
|
151
|
+
]
|
|
152
|
+
], [
|
|
153
|
+
_dec11
|
|
154
|
+
], _BaseEntity1));
|
|
155
|
+
}
|
|
156
|
+
static{
|
|
157
|
+
_initClass1();
|
|
158
|
+
}
|
|
159
|
+
constructor(...args){
|
|
160
|
+
super(...args), this.pk = (_initProto2(this), _init_pk(this)), this.picture = _init_picture(this);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
let _User;
|
|
164
|
+
_dec14 = Entity(), _dec15 = Field(), _dec16 = Field({
|
|
165
|
+
updatable: false
|
|
166
|
+
}), _dec17 = Field({
|
|
167
|
+
eager: false
|
|
168
|
+
}), _dec18 = OneToOne({
|
|
169
|
+
entity: ()=>_Profile,
|
|
170
|
+
mappedBy: (profile)=>profile.creator,
|
|
171
|
+
cascade: true
|
|
172
|
+
}), _dec19 = OneToMany({
|
|
173
|
+
entity: ()=>_User,
|
|
174
|
+
mappedBy: 'creator'
|
|
175
|
+
});
|
|
176
|
+
class User extends (_BaseEntity2 = BaseEntity) {
|
|
177
|
+
static{
|
|
178
|
+
({ e: [_init_name1, _init_email, _init_password, _init_profile, _init_users, _initProto3], c: [_User, _initClass2] } = _apply_decs_2203_r(this, [
|
|
179
|
+
[
|
|
180
|
+
_dec15,
|
|
181
|
+
0,
|
|
182
|
+
"name"
|
|
183
|
+
],
|
|
184
|
+
[
|
|
185
|
+
_dec16,
|
|
186
|
+
0,
|
|
187
|
+
"email"
|
|
188
|
+
],
|
|
189
|
+
[
|
|
190
|
+
_dec17,
|
|
191
|
+
0,
|
|
192
|
+
"password"
|
|
193
|
+
],
|
|
194
|
+
[
|
|
195
|
+
_dec18,
|
|
196
|
+
0,
|
|
197
|
+
"profile"
|
|
198
|
+
],
|
|
199
|
+
[
|
|
200
|
+
_dec19,
|
|
201
|
+
0,
|
|
202
|
+
"users"
|
|
203
|
+
]
|
|
204
|
+
], [
|
|
205
|
+
_dec14
|
|
206
|
+
], _BaseEntity2));
|
|
207
|
+
}
|
|
208
|
+
static{
|
|
209
|
+
_initClass2();
|
|
210
|
+
}
|
|
211
|
+
constructor(...args){
|
|
212
|
+
super(...args), this.name = (_initProto3(this), _init_name1(this)), this.email = _init_email(this), this.password = _init_password(this), this.profile = _init_profile(this), this.users = _init_users(this);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
let _UserWithNonUpdatableId;
|
|
216
|
+
_dec20 = Entity(), _dec21 = Id({
|
|
217
|
+
updatable: false
|
|
218
|
+
}), _dec22 = Field();
|
|
219
|
+
class UserWithNonUpdatableId {
|
|
220
|
+
static{
|
|
221
|
+
({ e: [_init_id1, _init_name2, _initProto4], c: [_UserWithNonUpdatableId, _initClass3] } = _apply_decs_2203_r(this, [
|
|
222
|
+
[
|
|
223
|
+
_dec21,
|
|
224
|
+
0,
|
|
225
|
+
"id"
|
|
226
|
+
],
|
|
227
|
+
[
|
|
228
|
+
_dec22,
|
|
229
|
+
0,
|
|
230
|
+
"name"
|
|
231
|
+
]
|
|
232
|
+
], [
|
|
233
|
+
_dec20
|
|
234
|
+
]));
|
|
235
|
+
}
|
|
236
|
+
static{
|
|
237
|
+
_initClass3();
|
|
238
|
+
}
|
|
239
|
+
constructor(){
|
|
240
|
+
this.id = (_initProto4(this), _init_id1(this));
|
|
241
|
+
this.name = _init_name2(this);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
let _LedgerAccount;
|
|
245
|
+
_dec23 = Entity(), _dec24 = Field(), _dec25 = Field(), _dec26 = Field({
|
|
246
|
+
references: ()=>_LedgerAccount
|
|
247
|
+
}), _dec27 = ManyToOne();
|
|
248
|
+
class LedgerAccount extends (_BaseEntity3 = BaseEntity) {
|
|
249
|
+
static{
|
|
250
|
+
({ e: [_init_name3, _init_description1, _init_parentLedgerId, _init_parentLedger, _initProto5], c: [_LedgerAccount, _initClass4] } = _apply_decs_2203_r(this, [
|
|
251
|
+
[
|
|
252
|
+
_dec24,
|
|
253
|
+
0,
|
|
254
|
+
"name"
|
|
255
|
+
],
|
|
256
|
+
[
|
|
257
|
+
_dec25,
|
|
258
|
+
0,
|
|
259
|
+
"description"
|
|
260
|
+
],
|
|
261
|
+
[
|
|
262
|
+
_dec26,
|
|
263
|
+
0,
|
|
264
|
+
"parentLedgerId"
|
|
265
|
+
],
|
|
266
|
+
[
|
|
267
|
+
_dec27,
|
|
268
|
+
0,
|
|
269
|
+
"parentLedger"
|
|
270
|
+
]
|
|
271
|
+
], [
|
|
272
|
+
_dec23
|
|
273
|
+
], _BaseEntity3));
|
|
274
|
+
}
|
|
275
|
+
static{
|
|
276
|
+
_initClass4();
|
|
277
|
+
}
|
|
278
|
+
constructor(...args){
|
|
279
|
+
super(...args), this.name = (_initProto5(this), _init_name3(this)), this.description = _init_description1(this), this.parentLedgerId = _init_parentLedgerId(this), this.parentLedger = _init_parentLedger(this);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
let _TaxCategory;
|
|
283
|
+
_dec28 = Entity(), _dec29 = Id({
|
|
284
|
+
onInsert: randomUUID
|
|
285
|
+
}), _dec30 = Field(), _dec31 = Field();
|
|
286
|
+
class TaxCategory extends (_BaseEntity4 = BaseEntity) {
|
|
287
|
+
static{
|
|
288
|
+
({ e: [_init_pk1, _init_name4, _init_description2, _initProto6], c: [_TaxCategory, _initClass5] } = _apply_decs_2203_r(this, [
|
|
289
|
+
[
|
|
290
|
+
_dec29,
|
|
291
|
+
0,
|
|
292
|
+
"pk"
|
|
293
|
+
],
|
|
294
|
+
[
|
|
295
|
+
_dec30,
|
|
296
|
+
0,
|
|
297
|
+
"name"
|
|
298
|
+
],
|
|
299
|
+
[
|
|
300
|
+
_dec31,
|
|
301
|
+
0,
|
|
302
|
+
"description"
|
|
303
|
+
]
|
|
304
|
+
], [
|
|
305
|
+
_dec28
|
|
306
|
+
], _BaseEntity4));
|
|
307
|
+
}
|
|
308
|
+
static{
|
|
309
|
+
_initClass5();
|
|
310
|
+
}
|
|
311
|
+
constructor(...args){
|
|
312
|
+
super(...args), this.pk = (_initProto6(this), _init_pk1(this)), this.name = _init_name4(this), this.description = _init_description2(this);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
let _Tax;
|
|
316
|
+
_dec32 = Entity(), _dec33 = Field(), _dec34 = Field(), _dec35 = Field({
|
|
317
|
+
references: ()=>_TaxCategory
|
|
318
|
+
}), _dec36 = ManyToOne(), _dec37 = Field();
|
|
319
|
+
class Tax extends (_BaseEntity5 = BaseEntity) {
|
|
320
|
+
static{
|
|
321
|
+
({ e: [_init_name5, _init_percentage, _init_categoryId, _init_category, _init_description3, _initProto7], c: [_Tax, _initClass6] } = _apply_decs_2203_r(this, [
|
|
322
|
+
[
|
|
323
|
+
_dec33,
|
|
324
|
+
0,
|
|
325
|
+
"name"
|
|
326
|
+
],
|
|
327
|
+
[
|
|
328
|
+
_dec34,
|
|
329
|
+
0,
|
|
330
|
+
"percentage"
|
|
331
|
+
],
|
|
332
|
+
[
|
|
333
|
+
_dec35,
|
|
334
|
+
0,
|
|
335
|
+
"categoryId"
|
|
336
|
+
],
|
|
337
|
+
[
|
|
338
|
+
_dec36,
|
|
339
|
+
0,
|
|
340
|
+
"category"
|
|
341
|
+
],
|
|
342
|
+
[
|
|
343
|
+
_dec37,
|
|
344
|
+
0,
|
|
345
|
+
"description"
|
|
346
|
+
]
|
|
347
|
+
], [
|
|
348
|
+
_dec32
|
|
349
|
+
], _BaseEntity5));
|
|
350
|
+
}
|
|
351
|
+
static{
|
|
352
|
+
_initClass6();
|
|
353
|
+
}
|
|
354
|
+
constructor(...args){
|
|
355
|
+
super(...args), this.name = (_initProto7(this), _init_name5(this)), this.percentage = _init_percentage(this), this.categoryId = _init_categoryId(this), this.category = _init_category(this), this.description = _init_description3(this);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
let _MeasureUnitCategory;
|
|
359
|
+
_dec38 = Entity({
|
|
360
|
+
softDelete: true
|
|
361
|
+
}), _dec39 = Field(), _dec40 = OneToMany({
|
|
362
|
+
entity: ()=>_MeasureUnit,
|
|
363
|
+
mappedBy: (measureUnit)=>measureUnit.categoryId
|
|
364
|
+
}), _dec41 = Field({
|
|
365
|
+
onDelete: Date.now
|
|
366
|
+
});
|
|
367
|
+
class MeasureUnitCategory extends (_BaseEntity6 = BaseEntity) {
|
|
368
|
+
static{
|
|
369
|
+
({ e: [_init_name6, _init_measureUnits, _init_deletedAt, _initProto8], c: [_MeasureUnitCategory, _initClass7] } = _apply_decs_2203_r(this, [
|
|
370
|
+
[
|
|
371
|
+
_dec39,
|
|
372
|
+
0,
|
|
373
|
+
"name"
|
|
374
|
+
],
|
|
375
|
+
[
|
|
376
|
+
_dec40,
|
|
377
|
+
0,
|
|
378
|
+
"measureUnits"
|
|
379
|
+
],
|
|
380
|
+
[
|
|
381
|
+
_dec41,
|
|
382
|
+
0,
|
|
383
|
+
"deletedAt"
|
|
384
|
+
]
|
|
385
|
+
], [
|
|
386
|
+
_dec38
|
|
387
|
+
], _BaseEntity6));
|
|
388
|
+
}
|
|
389
|
+
static{
|
|
390
|
+
_initClass7();
|
|
391
|
+
}
|
|
392
|
+
constructor(...args){
|
|
393
|
+
super(...args), this.name = (_initProto8(this), _init_name6(this)), this.measureUnits = _init_measureUnits(this), this.deletedAt = _init_deletedAt(this);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
let _MeasureUnit;
|
|
397
|
+
_dec42 = Entity({
|
|
398
|
+
softDelete: true
|
|
399
|
+
}), _dec43 = Field(), _dec44 = Field({
|
|
400
|
+
references: ()=>_MeasureUnitCategory
|
|
401
|
+
}), _dec45 = ManyToOne({
|
|
402
|
+
cascade: 'persist'
|
|
403
|
+
}), _dec46 = Field({
|
|
404
|
+
onDelete: Date.now
|
|
405
|
+
});
|
|
406
|
+
class MeasureUnit extends (_BaseEntity7 = BaseEntity) {
|
|
407
|
+
static{
|
|
408
|
+
({ e: [_init_name7, _init_categoryId1, _init_category1, _init_deletedAt1, _initProto9], c: [_MeasureUnit, _initClass8] } = _apply_decs_2203_r(this, [
|
|
409
|
+
[
|
|
410
|
+
_dec43,
|
|
411
|
+
0,
|
|
412
|
+
"name"
|
|
413
|
+
],
|
|
414
|
+
[
|
|
415
|
+
_dec44,
|
|
416
|
+
0,
|
|
417
|
+
"categoryId"
|
|
418
|
+
],
|
|
419
|
+
[
|
|
420
|
+
_dec45,
|
|
421
|
+
0,
|
|
422
|
+
"category"
|
|
423
|
+
],
|
|
424
|
+
[
|
|
425
|
+
_dec46,
|
|
426
|
+
0,
|
|
427
|
+
"deletedAt"
|
|
428
|
+
]
|
|
429
|
+
], [
|
|
430
|
+
_dec42
|
|
431
|
+
], _BaseEntity7));
|
|
432
|
+
}
|
|
433
|
+
static{
|
|
434
|
+
_initClass8();
|
|
435
|
+
}
|
|
436
|
+
constructor(...args){
|
|
437
|
+
super(...args), this.name = (_initProto9(this), _init_name7(this)), this.categoryId = _init_categoryId1(this), this.category = _init_category1(this), this.deletedAt = _init_deletedAt1(this);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
let _Storehouse;
|
|
441
|
+
_dec47 = Entity(), _dec48 = Field(), _dec49 = Field(), _dec50 = Field();
|
|
442
|
+
class Storehouse extends (_BaseEntity8 = BaseEntity) {
|
|
443
|
+
static{
|
|
444
|
+
({ e: [_init_name8, _init_address, _init_description4, _initProto10], c: [_Storehouse, _initClass9] } = _apply_decs_2203_r(this, [
|
|
445
|
+
[
|
|
446
|
+
_dec48,
|
|
447
|
+
0,
|
|
448
|
+
"name"
|
|
449
|
+
],
|
|
450
|
+
[
|
|
451
|
+
_dec49,
|
|
452
|
+
0,
|
|
453
|
+
"address"
|
|
454
|
+
],
|
|
455
|
+
[
|
|
456
|
+
_dec50,
|
|
457
|
+
0,
|
|
458
|
+
"description"
|
|
459
|
+
]
|
|
460
|
+
], [
|
|
461
|
+
_dec47
|
|
462
|
+
], _BaseEntity8));
|
|
463
|
+
}
|
|
464
|
+
static{
|
|
465
|
+
_initClass9();
|
|
466
|
+
}
|
|
467
|
+
constructor(...args){
|
|
468
|
+
super(...args), this.name = (_initProto10(this), _init_name8(this)), this.address = _init_address(this), this.description = _init_description4(this);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
let _Item;
|
|
472
|
+
_dec51 = Entity(), _dec52 = Field(), _dec53 = Field(), _dec54 = Field(), _dec55 = Field({
|
|
473
|
+
references: ()=>_LedgerAccount
|
|
474
|
+
}), _dec56 = ManyToOne(), _dec57 = Field({
|
|
475
|
+
references: ()=>_LedgerAccount
|
|
476
|
+
}), _dec58 = ManyToOne(), _dec59 = Field({
|
|
477
|
+
references: ()=>_Tax
|
|
478
|
+
}), _dec60 = ManyToOne(), _dec61 = Field({
|
|
479
|
+
references: ()=>_MeasureUnit
|
|
480
|
+
}), _dec62 = ManyToOne(), _dec63 = Field(), _dec64 = Field(), _dec65 = ManyToMany({
|
|
481
|
+
entity: ()=>_Tag,
|
|
482
|
+
through: ()=>_ItemTag,
|
|
483
|
+
cascade: true
|
|
484
|
+
}), _dec66 = Field({
|
|
485
|
+
/**
|
|
486
|
+
* `virtual` property allows defining the value for a non-persistent field,
|
|
487
|
+
* such value might be a scalar or a (`raw`) function. Virtual-fields can
|
|
488
|
+
* be used in `$select` and `$where` as a common field whose value is
|
|
489
|
+
* replaced is replaced at runtime.
|
|
490
|
+
*/ virtual: raw(({ ctx, escapedPrefix, dialect } = {})=>{
|
|
491
|
+
ctx.append('(');
|
|
492
|
+
dialect.count(ctx, _ItemTag, {
|
|
493
|
+
$where: {
|
|
494
|
+
itemId: raw(({ ctx: innerCtx } = {})=>{
|
|
495
|
+
innerCtx.append(escapedPrefix + dialect.escapeId('id'));
|
|
496
|
+
})
|
|
497
|
+
}
|
|
498
|
+
}, {
|
|
499
|
+
autoPrefix: true
|
|
500
|
+
});
|
|
501
|
+
ctx.append(')');
|
|
502
|
+
})
|
|
503
|
+
});
|
|
504
|
+
class Item extends (_BaseEntity9 = BaseEntity) {
|
|
505
|
+
static{
|
|
506
|
+
({ e: [_init_name9, _init_description5, _init_code, _init_buyLedgerAccountId, _init_buyLedgerAccount, _init_saleLedgerAccountId, _init_saleLedgerAccount, _init_taxId, _init_tax, _init_measureUnitId, _init_measureUnit, _init_salePrice, _init_inventoryable, _init_tags, _init_tagsCount, _initProto11], c: [_Item, _initClass10] } = _apply_decs_2203_r(this, [
|
|
507
|
+
[
|
|
508
|
+
_dec52,
|
|
509
|
+
0,
|
|
510
|
+
"name"
|
|
511
|
+
],
|
|
512
|
+
[
|
|
513
|
+
_dec53,
|
|
514
|
+
0,
|
|
515
|
+
"description"
|
|
516
|
+
],
|
|
517
|
+
[
|
|
518
|
+
_dec54,
|
|
519
|
+
0,
|
|
520
|
+
"code"
|
|
521
|
+
],
|
|
522
|
+
[
|
|
523
|
+
_dec55,
|
|
524
|
+
0,
|
|
525
|
+
"buyLedgerAccountId"
|
|
526
|
+
],
|
|
527
|
+
[
|
|
528
|
+
_dec56,
|
|
529
|
+
0,
|
|
530
|
+
"buyLedgerAccount"
|
|
531
|
+
],
|
|
532
|
+
[
|
|
533
|
+
_dec57,
|
|
534
|
+
0,
|
|
535
|
+
"saleLedgerAccountId"
|
|
536
|
+
],
|
|
537
|
+
[
|
|
538
|
+
_dec58,
|
|
539
|
+
0,
|
|
540
|
+
"saleLedgerAccount"
|
|
541
|
+
],
|
|
542
|
+
[
|
|
543
|
+
_dec59,
|
|
544
|
+
0,
|
|
545
|
+
"taxId"
|
|
546
|
+
],
|
|
547
|
+
[
|
|
548
|
+
_dec60,
|
|
549
|
+
0,
|
|
550
|
+
"tax"
|
|
551
|
+
],
|
|
552
|
+
[
|
|
553
|
+
_dec61,
|
|
554
|
+
0,
|
|
555
|
+
"measureUnitId"
|
|
556
|
+
],
|
|
557
|
+
[
|
|
558
|
+
_dec62,
|
|
559
|
+
0,
|
|
560
|
+
"measureUnit"
|
|
561
|
+
],
|
|
562
|
+
[
|
|
563
|
+
_dec63,
|
|
564
|
+
0,
|
|
565
|
+
"salePrice"
|
|
566
|
+
],
|
|
567
|
+
[
|
|
568
|
+
_dec64,
|
|
569
|
+
0,
|
|
570
|
+
"inventoryable"
|
|
571
|
+
],
|
|
572
|
+
[
|
|
573
|
+
_dec65,
|
|
574
|
+
0,
|
|
575
|
+
"tags"
|
|
576
|
+
],
|
|
577
|
+
[
|
|
578
|
+
_dec66,
|
|
579
|
+
0,
|
|
580
|
+
"tagsCount"
|
|
581
|
+
]
|
|
582
|
+
], [
|
|
583
|
+
_dec51
|
|
584
|
+
], _BaseEntity9));
|
|
585
|
+
}
|
|
586
|
+
static{
|
|
587
|
+
_initClass10();
|
|
588
|
+
}
|
|
589
|
+
constructor(...args){
|
|
590
|
+
super(...args), this.name = (_initProto11(this), _init_name9(this)), this.description = _init_description5(this), this.code = _init_code(this), this.buyLedgerAccountId = _init_buyLedgerAccountId(this), this.buyLedgerAccount = _init_buyLedgerAccount(this), this.saleLedgerAccountId = _init_saleLedgerAccountId(this), this.saleLedgerAccount = _init_saleLedgerAccount(this), this.taxId = _init_taxId(this), this.tax = _init_tax(this), this.measureUnitId = _init_measureUnitId(this), this.measureUnit = _init_measureUnit(this), this.salePrice = _init_salePrice(this), this.inventoryable = _init_inventoryable(this), this.tags = _init_tags(this), this.tagsCount = _init_tagsCount(this);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
let _Tag;
|
|
594
|
+
_dec67 = Entity(), _dec68 = Field(), _dec69 = ManyToMany({
|
|
595
|
+
entity: ()=>_Item,
|
|
596
|
+
mappedBy: (item)=>item.tags
|
|
597
|
+
}), _dec70 = Field({
|
|
598
|
+
virtual: raw(({ ctx, escapedPrefix, dialect } = {})=>{
|
|
599
|
+
ctx.append('(');
|
|
600
|
+
dialect.count(ctx, _ItemTag, {
|
|
601
|
+
$where: {
|
|
602
|
+
tagId: raw(({ ctx: innerCtx } = {})=>{
|
|
603
|
+
innerCtx.append(escapedPrefix + dialect.escapeId('id'));
|
|
604
|
+
})
|
|
605
|
+
}
|
|
606
|
+
}, {
|
|
607
|
+
autoPrefix: true
|
|
608
|
+
});
|
|
609
|
+
ctx.append(')');
|
|
610
|
+
})
|
|
611
|
+
});
|
|
612
|
+
class Tag extends (_BaseEntity10 = BaseEntity) {
|
|
613
|
+
static{
|
|
614
|
+
({ e: [_init_name10, _init_items, _init_itemsCount, _initProto12], c: [_Tag, _initClass11] } = _apply_decs_2203_r(this, [
|
|
615
|
+
[
|
|
616
|
+
_dec68,
|
|
617
|
+
0,
|
|
618
|
+
"name"
|
|
619
|
+
],
|
|
620
|
+
[
|
|
621
|
+
_dec69,
|
|
622
|
+
0,
|
|
623
|
+
"items"
|
|
624
|
+
],
|
|
625
|
+
[
|
|
626
|
+
_dec70,
|
|
627
|
+
0,
|
|
628
|
+
"itemsCount"
|
|
629
|
+
]
|
|
630
|
+
], [
|
|
631
|
+
_dec67
|
|
632
|
+
], _BaseEntity10));
|
|
633
|
+
}
|
|
634
|
+
static{
|
|
635
|
+
_initClass11();
|
|
636
|
+
}
|
|
637
|
+
constructor(...args){
|
|
638
|
+
super(...args), this.name = (_initProto12(this), _init_name10(this)), this.items = _init_items(this), this.itemsCount = _init_itemsCount(this);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
let _ItemTag;
|
|
642
|
+
_dec71 = Entity(), _dec72 = Id(), _dec73 = Field({
|
|
643
|
+
references: ()=>_Item
|
|
644
|
+
}), _dec74 = Field({
|
|
645
|
+
references: ()=>_Tag
|
|
646
|
+
});
|
|
647
|
+
class ItemTag {
|
|
648
|
+
static{
|
|
649
|
+
({ e: [_init_id2, _init_itemId, _init_tagId, _initProto13], c: [_ItemTag, _initClass12] } = _apply_decs_2203_r(this, [
|
|
650
|
+
[
|
|
651
|
+
_dec72,
|
|
652
|
+
0,
|
|
653
|
+
"id"
|
|
654
|
+
],
|
|
655
|
+
[
|
|
656
|
+
_dec73,
|
|
657
|
+
0,
|
|
658
|
+
"itemId"
|
|
659
|
+
],
|
|
660
|
+
[
|
|
661
|
+
_dec74,
|
|
662
|
+
0,
|
|
663
|
+
"tagId"
|
|
664
|
+
]
|
|
665
|
+
], [
|
|
666
|
+
_dec71
|
|
667
|
+
]));
|
|
668
|
+
}
|
|
669
|
+
static{
|
|
670
|
+
_initClass12();
|
|
671
|
+
}
|
|
672
|
+
constructor(){
|
|
673
|
+
this.id = (_initProto13(this), _init_id2(this));
|
|
674
|
+
this.itemId = _init_itemId(this);
|
|
675
|
+
this.tagId = _init_tagId(this);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
let _InventoryAdjustment;
|
|
679
|
+
_dec75 = Entity(), _dec76 = OneToMany({
|
|
680
|
+
entity: ()=>_ItemAdjustment,
|
|
681
|
+
mappedBy: (rel)=>rel.inventoryAdjustment,
|
|
682
|
+
cascade: true
|
|
683
|
+
}), _dec77 = Field(), _dec78 = Field();
|
|
684
|
+
class InventoryAdjustment extends (_BaseEntity11 = BaseEntity) {
|
|
685
|
+
static{
|
|
686
|
+
({ e: [_init_itemAdjustments, _init_date, _init_description6, _initProto14], c: [_InventoryAdjustment, _initClass13] } = _apply_decs_2203_r(this, [
|
|
687
|
+
[
|
|
688
|
+
_dec76,
|
|
689
|
+
0,
|
|
690
|
+
"itemAdjustments"
|
|
691
|
+
],
|
|
692
|
+
[
|
|
693
|
+
_dec77,
|
|
694
|
+
0,
|
|
695
|
+
"date"
|
|
696
|
+
],
|
|
697
|
+
[
|
|
698
|
+
_dec78,
|
|
699
|
+
0,
|
|
700
|
+
"description"
|
|
701
|
+
]
|
|
702
|
+
], [
|
|
703
|
+
_dec75
|
|
704
|
+
], _BaseEntity11));
|
|
705
|
+
}
|
|
706
|
+
static{
|
|
707
|
+
_initClass13();
|
|
708
|
+
}
|
|
709
|
+
constructor(...args){
|
|
710
|
+
super(...args), this.itemAdjustments = (_initProto14(this), _init_itemAdjustments(this)), this.date = _init_date(this), this.description = _init_description6(this);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
let _ItemAdjustment;
|
|
714
|
+
_dec79 = Entity(), _dec80 = Field({
|
|
715
|
+
references: ()=>_Item
|
|
716
|
+
}), _dec81 = ManyToOne(), _dec82 = Field(), _dec83 = Field(), _dec84 = Field({
|
|
717
|
+
references: ()=>_Storehouse
|
|
718
|
+
}), _dec85 = ManyToOne(), _dec86 = Field({
|
|
719
|
+
references: ()=>_InventoryAdjustment
|
|
720
|
+
}), _dec87 = ManyToOne();
|
|
721
|
+
class ItemAdjustment extends (_BaseEntity12 = BaseEntity) {
|
|
722
|
+
static{
|
|
723
|
+
({ e: [_init_itemId1, _init_item, _init_number, _init_buyPrice, _init_storehouseId, _init_storehouse, _init_inventoryAdjustmentId, _init_inventoryAdjustment, _initProto15], c: [_ItemAdjustment, _initClass14] } = _apply_decs_2203_r(this, [
|
|
724
|
+
[
|
|
725
|
+
_dec80,
|
|
726
|
+
0,
|
|
727
|
+
"itemId"
|
|
728
|
+
],
|
|
729
|
+
[
|
|
730
|
+
_dec81,
|
|
731
|
+
0,
|
|
732
|
+
"item"
|
|
733
|
+
],
|
|
734
|
+
[
|
|
735
|
+
_dec82,
|
|
736
|
+
0,
|
|
737
|
+
"number"
|
|
738
|
+
],
|
|
739
|
+
[
|
|
740
|
+
_dec83,
|
|
741
|
+
0,
|
|
742
|
+
"buyPrice"
|
|
743
|
+
],
|
|
744
|
+
[
|
|
745
|
+
_dec84,
|
|
746
|
+
0,
|
|
747
|
+
"storehouseId"
|
|
748
|
+
],
|
|
749
|
+
[
|
|
750
|
+
_dec85,
|
|
751
|
+
0,
|
|
752
|
+
"storehouse"
|
|
753
|
+
],
|
|
754
|
+
[
|
|
755
|
+
_dec86,
|
|
756
|
+
0,
|
|
757
|
+
"inventoryAdjustmentId"
|
|
758
|
+
],
|
|
759
|
+
[
|
|
760
|
+
_dec87,
|
|
761
|
+
0,
|
|
762
|
+
"inventoryAdjustment"
|
|
763
|
+
]
|
|
764
|
+
], [
|
|
765
|
+
_dec79
|
|
766
|
+
], _BaseEntity12));
|
|
767
|
+
}
|
|
768
|
+
static{
|
|
769
|
+
_initClass14();
|
|
770
|
+
}
|
|
771
|
+
constructor(...args){
|
|
772
|
+
super(...args), this.itemId = (_initProto15(this), _init_itemId1(this)), this.item = _init_item(this), this.number = _init_number(this), this.buyPrice = _init_buyPrice(this), this.storehouseId = _init_storehouseId(this), this.storehouse = _init_storehouse(this), this.inventoryAdjustmentId = _init_inventoryAdjustmentId(this), this.inventoryAdjustment = _init_inventoryAdjustment(this);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
const holder = globalThis;
|
|
777
|
+
const metaKey = 'uql-orm/entity/decorator';
|
|
778
|
+
const metas = holder[metaKey] ?? new Map();
|
|
779
|
+
holder[metaKey] = metas;
|
|
780
|
+
function getEntities() {
|
|
781
|
+
return [
|
|
782
|
+
...metas.entries()
|
|
783
|
+
].reduce((acc, [key, val])=>{
|
|
784
|
+
if (val.id) {
|
|
785
|
+
acc.push(key);
|
|
786
|
+
}
|
|
787
|
+
return acc;
|
|
788
|
+
}, []);
|
|
789
|
+
}
|
|
790
|
+
function ensureMeta(entity) {
|
|
791
|
+
let meta = metas.get(entity);
|
|
792
|
+
if (meta) {
|
|
793
|
+
return meta;
|
|
794
|
+
}
|
|
795
|
+
meta = {
|
|
796
|
+
entity,
|
|
797
|
+
fields: {},
|
|
798
|
+
relations: {}
|
|
799
|
+
};
|
|
800
|
+
metas.set(entity, meta);
|
|
801
|
+
return meta;
|
|
802
|
+
}
|
|
803
|
+
function getMeta(entity) {
|
|
804
|
+
const meta = metas.get(entity);
|
|
805
|
+
if (!meta) {
|
|
806
|
+
throw TypeError(`'${entity.name}' is not an entity`);
|
|
807
|
+
}
|
|
808
|
+
if (meta.processed) {
|
|
809
|
+
return meta;
|
|
810
|
+
}
|
|
811
|
+
meta.processed = true;
|
|
812
|
+
return fillRelations(meta);
|
|
813
|
+
}
|
|
814
|
+
function fillRelations(meta) {
|
|
815
|
+
for(const relKey in meta.relations){
|
|
816
|
+
const relOpts = meta.relations[relKey];
|
|
817
|
+
if (!relOpts) continue;
|
|
818
|
+
if (relOpts.references) {
|
|
819
|
+
continue;
|
|
820
|
+
}
|
|
821
|
+
if (relOpts.mappedBy) {
|
|
822
|
+
fillInverseSideRelations(relOpts);
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
const relEntity = relOpts.entity();
|
|
826
|
+
const relMeta = ensureMeta(relEntity);
|
|
827
|
+
if (relOpts.cardinality === 'mm') {
|
|
828
|
+
const idKey = meta.id;
|
|
829
|
+
const relIdKey = relMeta.id;
|
|
830
|
+
const idName = meta.fields[idKey]?.name ?? idKey;
|
|
831
|
+
const relIdName = relMeta.fields[relIdKey]?.name ?? relIdKey;
|
|
832
|
+
const source = lowerFirst(meta.name ?? '') + upperFirst(idName);
|
|
833
|
+
const target = lowerFirst(relMeta.name ?? '') + upperFirst(relIdName);
|
|
834
|
+
relOpts.references = [
|
|
835
|
+
{
|
|
836
|
+
local: source,
|
|
837
|
+
foreign: idKey
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
local: target,
|
|
841
|
+
foreign: relIdKey
|
|
842
|
+
}
|
|
843
|
+
];
|
|
844
|
+
} else {
|
|
845
|
+
const relIdKey = relMeta.id;
|
|
846
|
+
relOpts.references = [
|
|
847
|
+
{
|
|
848
|
+
local: `${relKey}Id`,
|
|
849
|
+
foreign: relIdKey
|
|
850
|
+
}
|
|
851
|
+
];
|
|
852
|
+
}
|
|
853
|
+
if (relOpts.through) {
|
|
854
|
+
fillThroughRelations(relOpts.through());
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
return meta;
|
|
858
|
+
}
|
|
859
|
+
function fillInverseSideRelations(relOpts) {
|
|
860
|
+
const relEntity = relOpts.entity();
|
|
861
|
+
const relMeta = getMeta(relEntity);
|
|
862
|
+
const mappedBy = getMappedByRelationKey(relOpts);
|
|
863
|
+
relOpts.mappedBy = mappedBy;
|
|
864
|
+
if (relMeta.fields[mappedBy]) {
|
|
865
|
+
relOpts.references = [
|
|
866
|
+
{
|
|
867
|
+
local: relMeta.id,
|
|
868
|
+
foreign: mappedBy
|
|
869
|
+
}
|
|
870
|
+
];
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
const mappedByRelation = relMeta.relations[mappedBy];
|
|
874
|
+
if (!mappedByRelation) return;
|
|
875
|
+
if (relOpts.cardinality === 'm1' || relOpts.cardinality === 'mm') {
|
|
876
|
+
relOpts.references = (mappedByRelation.references ?? []).slice().reverse();
|
|
877
|
+
relOpts.through = mappedByRelation.through;
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
relOpts.references = (mappedByRelation.references ?? []).map(({ local, foreign })=>({
|
|
881
|
+
local: foreign,
|
|
882
|
+
foreign: local
|
|
883
|
+
}));
|
|
884
|
+
}
|
|
885
|
+
function fillThroughRelations(entity) {
|
|
886
|
+
const meta = ensureMeta(entity);
|
|
887
|
+
meta.relations = getKeys(meta.fields).reduce((relations, key)=>{
|
|
888
|
+
const field = meta.fields[key];
|
|
889
|
+
if (!field) return relations;
|
|
890
|
+
const reference = field.references ?? field.reference;
|
|
891
|
+
if (reference) {
|
|
892
|
+
const relEntity = reference();
|
|
893
|
+
const relMeta = ensureMeta(relEntity);
|
|
894
|
+
const relIdKey = relMeta.id;
|
|
895
|
+
const relKey = key.slice(0, -relIdKey.length);
|
|
896
|
+
const relOpts = {
|
|
897
|
+
entity: reference,
|
|
898
|
+
cardinality: 'm1',
|
|
899
|
+
references: [
|
|
900
|
+
{
|
|
901
|
+
local: key,
|
|
902
|
+
foreign: relIdKey
|
|
903
|
+
}
|
|
904
|
+
]
|
|
905
|
+
};
|
|
906
|
+
relations[relKey] = relOpts;
|
|
907
|
+
}
|
|
908
|
+
return relations;
|
|
909
|
+
}, {});
|
|
910
|
+
}
|
|
911
|
+
function getMappedByRelationKey(relOpts) {
|
|
912
|
+
if (typeof relOpts.mappedBy === 'function') {
|
|
913
|
+
const relEntity = relOpts.entity();
|
|
914
|
+
const relMeta = ensureMeta(relEntity);
|
|
915
|
+
const keyMap = getRelationKeyMap(relMeta);
|
|
916
|
+
return relOpts.mappedBy(keyMap);
|
|
917
|
+
}
|
|
918
|
+
return relOpts.mappedBy;
|
|
919
|
+
}
|
|
920
|
+
function getRelationKeyMap(meta) {
|
|
921
|
+
const keys = [
|
|
922
|
+
...getKeys(meta.fields),
|
|
923
|
+
...getKeys(meta.relations)
|
|
924
|
+
];
|
|
925
|
+
return keys.reduce((acc, key)=>{
|
|
926
|
+
acc[key] = key;
|
|
927
|
+
return acc;
|
|
928
|
+
}, {});
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
async function createTables(querier, primaryKeyType) {
|
|
932
|
+
const entities = getEntities();
|
|
933
|
+
await Promise.all(entities.map((entity)=>{
|
|
934
|
+
const sql = getDdlForTable(entity, querier, primaryKeyType);
|
|
935
|
+
return querier.run(sql);
|
|
936
|
+
}));
|
|
937
|
+
}
|
|
938
|
+
async function dropTables(querier) {
|
|
939
|
+
const entities = getEntities();
|
|
940
|
+
await Promise.all(entities.map((entity)=>{
|
|
941
|
+
const meta = getMeta(entity);
|
|
942
|
+
const sql = `DROP TABLE IF EXISTS ${querier.dialect.escapeId(meta.name)}`;
|
|
943
|
+
return querier.run(sql);
|
|
944
|
+
}));
|
|
945
|
+
}
|
|
946
|
+
async function clearTables(querier) {
|
|
947
|
+
const entities = getEntities();
|
|
948
|
+
await Promise.all(entities.map((entity)=>{
|
|
949
|
+
const ctx = querier.dialect.createContext();
|
|
950
|
+
querier.dialect.delete(ctx, entity, {});
|
|
951
|
+
return querier.run(ctx.sql, ctx.values);
|
|
952
|
+
}));
|
|
953
|
+
}
|
|
954
|
+
function getDdlForTable(entity, querier, primaryKeyType) {
|
|
955
|
+
const meta = getMeta(entity);
|
|
956
|
+
let sql = `CREATE TABLE ${querier.dialect.escapeId(meta.name)} (\n\t`;
|
|
957
|
+
const insertableIdType = 'VARCHAR(36)';
|
|
958
|
+
const defaultType = querier.dialect.escapeIdChar === '"' ? 'TEXT' : 'VARCHAR(255)';
|
|
959
|
+
const columns = getKeys(meta.fields).map((key)=>{
|
|
960
|
+
const field = meta.fields[key];
|
|
961
|
+
let propSql = querier.dialect.escapeId(field.name) + ' ';
|
|
962
|
+
if (field.isId) {
|
|
963
|
+
propSql += field.onInsert ? `${insertableIdType} PRIMARY KEY` : primaryKeyType;
|
|
964
|
+
} else {
|
|
965
|
+
if (field.type === Number) {
|
|
966
|
+
propSql += 'BIGINT';
|
|
967
|
+
} else if (field.type === Date) {
|
|
968
|
+
propSql += 'TIMESTAMP';
|
|
969
|
+
} else {
|
|
970
|
+
propSql += defaultType;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
return propSql;
|
|
974
|
+
});
|
|
975
|
+
sql += columns.join(',\n\t');
|
|
976
|
+
sql += `\n);`;
|
|
977
|
+
// log('sql', sql);
|
|
978
|
+
return sql;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
// src/index.ts
|
|
982
|
+
var d = {
|
|
983
|
+
reset: [
|
|
984
|
+
0,
|
|
985
|
+
0
|
|
986
|
+
],
|
|
987
|
+
bold: [
|
|
988
|
+
1,
|
|
989
|
+
22,
|
|
990
|
+
"\x1B[22m\x1B[1m"
|
|
991
|
+
],
|
|
992
|
+
dim: [
|
|
993
|
+
2,
|
|
994
|
+
22,
|
|
995
|
+
"\x1B[22m\x1B[2m"
|
|
996
|
+
],
|
|
997
|
+
italic: [
|
|
998
|
+
3,
|
|
999
|
+
23
|
|
1000
|
+
],
|
|
1001
|
+
underline: [
|
|
1002
|
+
4,
|
|
1003
|
+
24
|
|
1004
|
+
],
|
|
1005
|
+
inverse: [
|
|
1006
|
+
7,
|
|
1007
|
+
27
|
|
1008
|
+
],
|
|
1009
|
+
hidden: [
|
|
1010
|
+
8,
|
|
1011
|
+
28
|
|
1012
|
+
],
|
|
1013
|
+
strikethrough: [
|
|
1014
|
+
9,
|
|
1015
|
+
29
|
|
1016
|
+
],
|
|
1017
|
+
black: [
|
|
1018
|
+
30,
|
|
1019
|
+
39
|
|
1020
|
+
],
|
|
1021
|
+
red: [
|
|
1022
|
+
31,
|
|
1023
|
+
39
|
|
1024
|
+
],
|
|
1025
|
+
green: [
|
|
1026
|
+
32,
|
|
1027
|
+
39
|
|
1028
|
+
],
|
|
1029
|
+
yellow: [
|
|
1030
|
+
33,
|
|
1031
|
+
39
|
|
1032
|
+
],
|
|
1033
|
+
blue: [
|
|
1034
|
+
34,
|
|
1035
|
+
39
|
|
1036
|
+
],
|
|
1037
|
+
magenta: [
|
|
1038
|
+
35,
|
|
1039
|
+
39
|
|
1040
|
+
],
|
|
1041
|
+
cyan: [
|
|
1042
|
+
36,
|
|
1043
|
+
39
|
|
1044
|
+
],
|
|
1045
|
+
white: [
|
|
1046
|
+
37,
|
|
1047
|
+
39
|
|
1048
|
+
],
|
|
1049
|
+
gray: [
|
|
1050
|
+
90,
|
|
1051
|
+
39
|
|
1052
|
+
],
|
|
1053
|
+
bgBlack: [
|
|
1054
|
+
40,
|
|
1055
|
+
49
|
|
1056
|
+
],
|
|
1057
|
+
bgRed: [
|
|
1058
|
+
41,
|
|
1059
|
+
49
|
|
1060
|
+
],
|
|
1061
|
+
bgGreen: [
|
|
1062
|
+
42,
|
|
1063
|
+
49
|
|
1064
|
+
],
|
|
1065
|
+
bgYellow: [
|
|
1066
|
+
43,
|
|
1067
|
+
49
|
|
1068
|
+
],
|
|
1069
|
+
bgBlue: [
|
|
1070
|
+
44,
|
|
1071
|
+
49
|
|
1072
|
+
],
|
|
1073
|
+
bgMagenta: [
|
|
1074
|
+
45,
|
|
1075
|
+
49
|
|
1076
|
+
],
|
|
1077
|
+
bgCyan: [
|
|
1078
|
+
46,
|
|
1079
|
+
49
|
|
1080
|
+
],
|
|
1081
|
+
bgWhite: [
|
|
1082
|
+
47,
|
|
1083
|
+
49
|
|
1084
|
+
],
|
|
1085
|
+
blackBright: [
|
|
1086
|
+
90,
|
|
1087
|
+
39
|
|
1088
|
+
],
|
|
1089
|
+
redBright: [
|
|
1090
|
+
91,
|
|
1091
|
+
39
|
|
1092
|
+
],
|
|
1093
|
+
greenBright: [
|
|
1094
|
+
92,
|
|
1095
|
+
39
|
|
1096
|
+
],
|
|
1097
|
+
yellowBright: [
|
|
1098
|
+
93,
|
|
1099
|
+
39
|
|
1100
|
+
],
|
|
1101
|
+
blueBright: [
|
|
1102
|
+
94,
|
|
1103
|
+
39
|
|
1104
|
+
],
|
|
1105
|
+
magentaBright: [
|
|
1106
|
+
95,
|
|
1107
|
+
39
|
|
1108
|
+
],
|
|
1109
|
+
cyanBright: [
|
|
1110
|
+
96,
|
|
1111
|
+
39
|
|
1112
|
+
],
|
|
1113
|
+
whiteBright: [
|
|
1114
|
+
97,
|
|
1115
|
+
39
|
|
1116
|
+
],
|
|
1117
|
+
bgBlackBright: [
|
|
1118
|
+
100,
|
|
1119
|
+
49
|
|
1120
|
+
],
|
|
1121
|
+
bgRedBright: [
|
|
1122
|
+
101,
|
|
1123
|
+
49
|
|
1124
|
+
],
|
|
1125
|
+
bgGreenBright: [
|
|
1126
|
+
102,
|
|
1127
|
+
49
|
|
1128
|
+
],
|
|
1129
|
+
bgYellowBright: [
|
|
1130
|
+
103,
|
|
1131
|
+
49
|
|
1132
|
+
],
|
|
1133
|
+
bgBlueBright: [
|
|
1134
|
+
104,
|
|
1135
|
+
49
|
|
1136
|
+
],
|
|
1137
|
+
bgMagentaBright: [
|
|
1138
|
+
105,
|
|
1139
|
+
49
|
|
1140
|
+
],
|
|
1141
|
+
bgCyanBright: [
|
|
1142
|
+
106,
|
|
1143
|
+
49
|
|
1144
|
+
],
|
|
1145
|
+
bgWhiteBright: [
|
|
1146
|
+
107,
|
|
1147
|
+
49
|
|
1148
|
+
]
|
|
1149
|
+
};
|
|
1150
|
+
function g(e) {
|
|
1151
|
+
return String(e);
|
|
1152
|
+
}
|
|
1153
|
+
g.open = "";
|
|
1154
|
+
g.close = "";
|
|
1155
|
+
function h() {
|
|
1156
|
+
let e = typeof process != "undefined" ? process : void 0, n = (e == null ? void 0 : e.env) || {}, a = n.FORCE_TTY !== "false", i = (e == null ? void 0 : e.argv) || [];
|
|
1157
|
+
return !("NO_COLOR" in n || i.includes("--no-color")) && ("FORCE_COLOR" in n || i.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || a && n.TERM !== "dumb" || "CI" in n) || typeof window != "undefined" && !!window.chrome;
|
|
1158
|
+
}
|
|
1159
|
+
function f() {
|
|
1160
|
+
let e = h(), n = (r, t, u, o)=>{
|
|
1161
|
+
let l = "", s = 0;
|
|
1162
|
+
do l += r.substring(s, o) + u, s = o + t.length, o = r.indexOf(t, s);
|
|
1163
|
+
while (~o)
|
|
1164
|
+
return l + r.substring(s);
|
|
1165
|
+
}, a = (r, t, u = r)=>{
|
|
1166
|
+
let o = (l)=>{
|
|
1167
|
+
let s = String(l), b = s.indexOf(t, r.length);
|
|
1168
|
+
return ~b ? r + n(s, t, u, b) + t : r + s + t;
|
|
1169
|
+
};
|
|
1170
|
+
return o.open = r, o.close = t, o;
|
|
1171
|
+
}, i = {
|
|
1172
|
+
isColorSupported: e
|
|
1173
|
+
}, c = (r)=>`\x1B[${r}m`;
|
|
1174
|
+
for(let r in d){
|
|
1175
|
+
let t = d[r];
|
|
1176
|
+
i[r] = e ? a(c(t[0]), c(t[1]), t[2]) : g;
|
|
1177
|
+
}
|
|
1178
|
+
return i;
|
|
1179
|
+
}
|
|
1180
|
+
var C = f();
|
|
1181
|
+
|
|
1182
|
+
function _mergeNamespaces$1(n, m) {
|
|
1183
|
+
m.forEach(function(e) {
|
|
1184
|
+
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function(k) {
|
|
1185
|
+
if (k !== 'default' && !(k in n)) {
|
|
1186
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
1187
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
1188
|
+
enumerable: true,
|
|
1189
|
+
get: function() {
|
|
1190
|
+
return e[k];
|
|
1191
|
+
}
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
});
|
|
1195
|
+
});
|
|
1196
|
+
return Object.freeze(n);
|
|
1197
|
+
}
|
|
1198
|
+
function getKeysOfEnumerableProperties(object, compareKeys) {
|
|
1199
|
+
const rawKeys = Object.keys(object);
|
|
1200
|
+
const keys = compareKeys === null ? rawKeys : rawKeys.sort(compareKeys);
|
|
1201
|
+
if (Object.getOwnPropertySymbols) {
|
|
1202
|
+
for (const symbol of Object.getOwnPropertySymbols(object)){
|
|
1203
|
+
if (Object.getOwnPropertyDescriptor(object, symbol).enumerable) {
|
|
1204
|
+
keys.push(symbol);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
return keys;
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* Return entries (for example, of a map)
|
|
1212
|
+
* with spacing, indentation, and comma
|
|
1213
|
+
* without surrounding punctuation (for example, braces)
|
|
1214
|
+
*/ function printIteratorEntries(iterator, config, indentation, depth, refs, printer, separator = ": ") {
|
|
1215
|
+
let result = "";
|
|
1216
|
+
let width = 0;
|
|
1217
|
+
let current = iterator.next();
|
|
1218
|
+
if (!current.done) {
|
|
1219
|
+
result += config.spacingOuter;
|
|
1220
|
+
const indentationNext = indentation + config.indent;
|
|
1221
|
+
while(!current.done){
|
|
1222
|
+
result += indentationNext;
|
|
1223
|
+
if (width++ === config.maxWidth) {
|
|
1224
|
+
result += "…";
|
|
1225
|
+
break;
|
|
1226
|
+
}
|
|
1227
|
+
const name = printer(current.value[0], config, indentationNext, depth, refs);
|
|
1228
|
+
const value = printer(current.value[1], config, indentationNext, depth, refs);
|
|
1229
|
+
result += name + separator + value;
|
|
1230
|
+
current = iterator.next();
|
|
1231
|
+
if (!current.done) {
|
|
1232
|
+
result += `,${config.spacingInner}`;
|
|
1233
|
+
} else if (!config.min) {
|
|
1234
|
+
result += ",";
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
result += config.spacingOuter + indentation;
|
|
1238
|
+
}
|
|
1239
|
+
return result;
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* Return values (for example, of a set)
|
|
1243
|
+
* with spacing, indentation, and comma
|
|
1244
|
+
* without surrounding punctuation (braces or brackets)
|
|
1245
|
+
*/ function printIteratorValues(iterator, config, indentation, depth, refs, printer) {
|
|
1246
|
+
let result = "";
|
|
1247
|
+
let width = 0;
|
|
1248
|
+
let current = iterator.next();
|
|
1249
|
+
if (!current.done) {
|
|
1250
|
+
result += config.spacingOuter;
|
|
1251
|
+
const indentationNext = indentation + config.indent;
|
|
1252
|
+
while(!current.done){
|
|
1253
|
+
result += indentationNext;
|
|
1254
|
+
if (width++ === config.maxWidth) {
|
|
1255
|
+
result += "…";
|
|
1256
|
+
break;
|
|
1257
|
+
}
|
|
1258
|
+
result += printer(current.value, config, indentationNext, depth, refs);
|
|
1259
|
+
current = iterator.next();
|
|
1260
|
+
if (!current.done) {
|
|
1261
|
+
result += `,${config.spacingInner}`;
|
|
1262
|
+
} else if (!config.min) {
|
|
1263
|
+
result += ",";
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
result += config.spacingOuter + indentation;
|
|
1267
|
+
}
|
|
1268
|
+
return result;
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Return items (for example, of an array)
|
|
1272
|
+
* with spacing, indentation, and comma
|
|
1273
|
+
* without surrounding punctuation (for example, brackets)
|
|
1274
|
+
*/ function printListItems(list, config, indentation, depth, refs, printer) {
|
|
1275
|
+
let result = "";
|
|
1276
|
+
list = list instanceof ArrayBuffer ? new DataView(list) : list;
|
|
1277
|
+
const isDataView = (l)=>l instanceof DataView;
|
|
1278
|
+
const length = isDataView(list) ? list.byteLength : list.length;
|
|
1279
|
+
if (length > 0) {
|
|
1280
|
+
result += config.spacingOuter;
|
|
1281
|
+
const indentationNext = indentation + config.indent;
|
|
1282
|
+
for(let i = 0; i < length; i++){
|
|
1283
|
+
result += indentationNext;
|
|
1284
|
+
if (i === config.maxWidth) {
|
|
1285
|
+
result += "…";
|
|
1286
|
+
break;
|
|
1287
|
+
}
|
|
1288
|
+
if (isDataView(list) || i in list) {
|
|
1289
|
+
result += printer(isDataView(list) ? list.getInt8(i) : list[i], config, indentationNext, depth, refs);
|
|
1290
|
+
}
|
|
1291
|
+
if (i < length - 1) {
|
|
1292
|
+
result += `,${config.spacingInner}`;
|
|
1293
|
+
} else if (!config.min) {
|
|
1294
|
+
result += ",";
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
result += config.spacingOuter + indentation;
|
|
1298
|
+
}
|
|
1299
|
+
return result;
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* Return properties of an object
|
|
1303
|
+
* with spacing, indentation, and comma
|
|
1304
|
+
* without surrounding punctuation (for example, braces)
|
|
1305
|
+
*/ function printObjectProperties(val, config, indentation, depth, refs, printer) {
|
|
1306
|
+
let result = "";
|
|
1307
|
+
const keys = getKeysOfEnumerableProperties(val, config.compareKeys);
|
|
1308
|
+
if (keys.length > 0) {
|
|
1309
|
+
result += config.spacingOuter;
|
|
1310
|
+
const indentationNext = indentation + config.indent;
|
|
1311
|
+
for(let i = 0; i < keys.length; i++){
|
|
1312
|
+
const key = keys[i];
|
|
1313
|
+
const name = printer(key, config, indentationNext, depth, refs);
|
|
1314
|
+
const value = printer(val[key], config, indentationNext, depth, refs);
|
|
1315
|
+
result += `${indentationNext + name}: ${value}`;
|
|
1316
|
+
if (i < keys.length - 1) {
|
|
1317
|
+
result += `,${config.spacingInner}`;
|
|
1318
|
+
} else if (!config.min) {
|
|
1319
|
+
result += ",";
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
result += config.spacingOuter + indentation;
|
|
1323
|
+
}
|
|
1324
|
+
return result;
|
|
1325
|
+
}
|
|
1326
|
+
const asymmetricMatcher = typeof Symbol === "function" && Symbol.for ? Symbol.for("jest.asymmetricMatcher") : 1267621;
|
|
1327
|
+
const SPACE$2 = " ";
|
|
1328
|
+
const serialize$5 = (val, config, indentation, depth, refs, printer)=>{
|
|
1329
|
+
const stringedValue = val.toString();
|
|
1330
|
+
if (stringedValue === "ArrayContaining" || stringedValue === "ArrayNotContaining") {
|
|
1331
|
+
if (++depth > config.maxDepth) {
|
|
1332
|
+
return `[${stringedValue}]`;
|
|
1333
|
+
}
|
|
1334
|
+
return `${stringedValue + SPACE$2}[${printListItems(val.sample, config, indentation, depth, refs, printer)}]`;
|
|
1335
|
+
}
|
|
1336
|
+
if (stringedValue === "ObjectContaining" || stringedValue === "ObjectNotContaining") {
|
|
1337
|
+
if (++depth > config.maxDepth) {
|
|
1338
|
+
return `[${stringedValue}]`;
|
|
1339
|
+
}
|
|
1340
|
+
return `${stringedValue + SPACE$2}{${printObjectProperties(val.sample, config, indentation, depth, refs, printer)}}`;
|
|
1341
|
+
}
|
|
1342
|
+
if (stringedValue === "StringMatching" || stringedValue === "StringNotMatching") {
|
|
1343
|
+
return stringedValue + SPACE$2 + printer(val.sample, config, indentation, depth, refs);
|
|
1344
|
+
}
|
|
1345
|
+
if (stringedValue === "StringContaining" || stringedValue === "StringNotContaining") {
|
|
1346
|
+
return stringedValue + SPACE$2 + printer(val.sample, config, indentation, depth, refs);
|
|
1347
|
+
}
|
|
1348
|
+
if (typeof val.toAsymmetricMatcher !== "function") {
|
|
1349
|
+
throw new TypeError(`Asymmetric matcher ${val.constructor.name} does not implement toAsymmetricMatcher()`);
|
|
1350
|
+
}
|
|
1351
|
+
return val.toAsymmetricMatcher();
|
|
1352
|
+
};
|
|
1353
|
+
const test$5 = (val)=>val && val.$$typeof === asymmetricMatcher;
|
|
1354
|
+
const plugin$5 = {
|
|
1355
|
+
serialize: serialize$5,
|
|
1356
|
+
test: test$5
|
|
1357
|
+
};
|
|
1358
|
+
const SPACE$1 = " ";
|
|
1359
|
+
const OBJECT_NAMES = new Set([
|
|
1360
|
+
"DOMStringMap",
|
|
1361
|
+
"NamedNodeMap"
|
|
1362
|
+
]);
|
|
1363
|
+
const ARRAY_REGEXP = /^(?:HTML\w*Collection|NodeList)$/;
|
|
1364
|
+
function testName(name) {
|
|
1365
|
+
return OBJECT_NAMES.has(name) || ARRAY_REGEXP.test(name);
|
|
1366
|
+
}
|
|
1367
|
+
const test$4 = (val)=>val && val.constructor && !!val.constructor.name && testName(val.constructor.name);
|
|
1368
|
+
function isNamedNodeMap(collection) {
|
|
1369
|
+
return collection.constructor.name === "NamedNodeMap";
|
|
1370
|
+
}
|
|
1371
|
+
const serialize$4 = (collection, config, indentation, depth, refs, printer)=>{
|
|
1372
|
+
const name = collection.constructor.name;
|
|
1373
|
+
if (++depth > config.maxDepth) {
|
|
1374
|
+
return `[${name}]`;
|
|
1375
|
+
}
|
|
1376
|
+
return (config.min ? "" : name + SPACE$1) + (OBJECT_NAMES.has(name) ? `{${printObjectProperties(isNamedNodeMap(collection) ? [
|
|
1377
|
+
...collection
|
|
1378
|
+
].reduce((props, attribute)=>{
|
|
1379
|
+
props[attribute.name] = attribute.value;
|
|
1380
|
+
return props;
|
|
1381
|
+
}, {}) : {
|
|
1382
|
+
...collection
|
|
1383
|
+
}, config, indentation, depth, refs, printer)}}` : `[${printListItems([
|
|
1384
|
+
...collection
|
|
1385
|
+
], config, indentation, depth, refs, printer)}]`);
|
|
1386
|
+
};
|
|
1387
|
+
const plugin$4 = {
|
|
1388
|
+
serialize: serialize$4,
|
|
1389
|
+
test: test$4
|
|
1390
|
+
};
|
|
1391
|
+
/**
|
|
1392
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1393
|
+
*
|
|
1394
|
+
* This source code is licensed under the MIT license found in the
|
|
1395
|
+
* LICENSE file in the root directory of this source tree.
|
|
1396
|
+
*/ function escapeHTML(str) {
|
|
1397
|
+
return str.replaceAll("<", "<").replaceAll(">", ">");
|
|
1398
|
+
}
|
|
1399
|
+
// Return empty string if keys is empty.
|
|
1400
|
+
function printProps(keys, props, config, indentation, depth, refs, printer) {
|
|
1401
|
+
const indentationNext = indentation + config.indent;
|
|
1402
|
+
const colors = config.colors;
|
|
1403
|
+
return keys.map((key)=>{
|
|
1404
|
+
const value = props[key];
|
|
1405
|
+
// hidden injected value that should not be printed
|
|
1406
|
+
if (typeof value === "string" && value[0] === "_" && value.startsWith("__vitest_") && value.match(/__vitest_\d+__/)) {
|
|
1407
|
+
return "";
|
|
1408
|
+
}
|
|
1409
|
+
let printed = printer(value, config, indentationNext, depth, refs);
|
|
1410
|
+
if (typeof value !== "string") {
|
|
1411
|
+
if (printed.includes("\n")) {
|
|
1412
|
+
printed = config.spacingOuter + indentationNext + printed + config.spacingOuter + indentation;
|
|
1413
|
+
}
|
|
1414
|
+
printed = `{${printed}}`;
|
|
1415
|
+
}
|
|
1416
|
+
return `${config.spacingInner + indentation + colors.prop.open + key + colors.prop.close}=${colors.value.open}${printed}${colors.value.close}`;
|
|
1417
|
+
}).join("");
|
|
1418
|
+
}
|
|
1419
|
+
// Return empty string if children is empty.
|
|
1420
|
+
function printChildren(children, config, indentation, depth, refs, printer) {
|
|
1421
|
+
return children.map((child)=>config.spacingOuter + indentation + (typeof child === "string" ? printText(child, config) : printer(child, config, indentation, depth, refs))).join("");
|
|
1422
|
+
}
|
|
1423
|
+
function printShadowRoot(children, config, indentation, depth, refs, printer) {
|
|
1424
|
+
if (config.printShadowRoot === false) {
|
|
1425
|
+
return "";
|
|
1426
|
+
}
|
|
1427
|
+
return [
|
|
1428
|
+
`${config.spacingOuter + indentation}#shadow-root`,
|
|
1429
|
+
printChildren(children, config, indentation + config.indent, depth, refs, printer)
|
|
1430
|
+
].join("");
|
|
1431
|
+
}
|
|
1432
|
+
function printText(text, config) {
|
|
1433
|
+
const contentColor = config.colors.content;
|
|
1434
|
+
return contentColor.open + escapeHTML(text) + contentColor.close;
|
|
1435
|
+
}
|
|
1436
|
+
function printComment(comment, config) {
|
|
1437
|
+
const commentColor = config.colors.comment;
|
|
1438
|
+
return `${commentColor.open}<!--${escapeHTML(comment)}-->${commentColor.close}`;
|
|
1439
|
+
}
|
|
1440
|
+
// Separate the functions to format props, children, and element,
|
|
1441
|
+
// so a plugin could override a particular function, if needed.
|
|
1442
|
+
// Too bad, so sad: the traditional (but unnecessary) space
|
|
1443
|
+
// in a self-closing tagColor requires a second test of printedProps.
|
|
1444
|
+
function printElement(type, printedProps, printedChildren, config, indentation) {
|
|
1445
|
+
const tagColor = config.colors.tag;
|
|
1446
|
+
return `${tagColor.open}<${type}${printedProps && tagColor.close + printedProps + config.spacingOuter + indentation + tagColor.open}${printedChildren ? `>${tagColor.close}${printedChildren}${config.spacingOuter}${indentation}${tagColor.open}</${type}` : `${printedProps && !config.min ? "" : " "}/`}>${tagColor.close}`;
|
|
1447
|
+
}
|
|
1448
|
+
function printElementAsLeaf(type, config) {
|
|
1449
|
+
const tagColor = config.colors.tag;
|
|
1450
|
+
return `${tagColor.open}<${type}${tagColor.close} …${tagColor.open} />${tagColor.close}`;
|
|
1451
|
+
}
|
|
1452
|
+
const ELEMENT_NODE = 1;
|
|
1453
|
+
const TEXT_NODE = 3;
|
|
1454
|
+
const COMMENT_NODE = 8;
|
|
1455
|
+
const FRAGMENT_NODE = 11;
|
|
1456
|
+
const ELEMENT_REGEXP = /^(?:(?:HTML|SVG)\w*)?Element$/;
|
|
1457
|
+
function testHasAttribute(val) {
|
|
1458
|
+
try {
|
|
1459
|
+
return typeof val.hasAttribute === "function" && val.hasAttribute("is");
|
|
1460
|
+
} catch {
|
|
1461
|
+
return false;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
function testNode(val) {
|
|
1465
|
+
const constructorName = val.constructor.name;
|
|
1466
|
+
const { nodeType, tagName } = val;
|
|
1467
|
+
const isCustomElement = typeof tagName === "string" && tagName.includes("-") || testHasAttribute(val);
|
|
1468
|
+
return nodeType === ELEMENT_NODE && (ELEMENT_REGEXP.test(constructorName) || isCustomElement) || nodeType === TEXT_NODE && constructorName === "Text" || nodeType === COMMENT_NODE && constructorName === "Comment" || nodeType === FRAGMENT_NODE && constructorName === "DocumentFragment";
|
|
1469
|
+
}
|
|
1470
|
+
const test$3 = (val)=>val?.constructor?.name && testNode(val);
|
|
1471
|
+
function nodeIsText(node) {
|
|
1472
|
+
return node.nodeType === TEXT_NODE;
|
|
1473
|
+
}
|
|
1474
|
+
function nodeIsComment(node) {
|
|
1475
|
+
return node.nodeType === COMMENT_NODE;
|
|
1476
|
+
}
|
|
1477
|
+
function nodeIsFragment(node) {
|
|
1478
|
+
return node.nodeType === FRAGMENT_NODE;
|
|
1479
|
+
}
|
|
1480
|
+
const serialize$3 = (node, config, indentation, depth, refs, printer)=>{
|
|
1481
|
+
if (nodeIsText(node)) {
|
|
1482
|
+
return printText(node.data, config);
|
|
1483
|
+
}
|
|
1484
|
+
if (nodeIsComment(node)) {
|
|
1485
|
+
return printComment(node.data, config);
|
|
1486
|
+
}
|
|
1487
|
+
const type = nodeIsFragment(node) ? "DocumentFragment" : node.tagName.toLowerCase();
|
|
1488
|
+
if (++depth > config.maxDepth) {
|
|
1489
|
+
return printElementAsLeaf(type, config);
|
|
1490
|
+
}
|
|
1491
|
+
return printElement(type, printProps(nodeIsFragment(node) ? [] : Array.from(node.attributes, (attr)=>attr.name).sort(), nodeIsFragment(node) ? {} : [
|
|
1492
|
+
...node.attributes
|
|
1493
|
+
].reduce((props, attribute)=>{
|
|
1494
|
+
props[attribute.name] = attribute.value;
|
|
1495
|
+
return props;
|
|
1496
|
+
}, {}), config, indentation + config.indent, depth, refs, printer), (nodeIsFragment(node) || !node.shadowRoot ? "" : printShadowRoot(Array.prototype.slice.call(node.shadowRoot.children), config, indentation + config.indent, depth, refs, printer)) + printChildren(Array.prototype.slice.call(node.childNodes || node.children), config, indentation + config.indent, depth, refs, printer), config, indentation);
|
|
1497
|
+
};
|
|
1498
|
+
const plugin$3 = {
|
|
1499
|
+
serialize: serialize$3,
|
|
1500
|
+
test: test$3
|
|
1501
|
+
};
|
|
1502
|
+
// SENTINEL constants are from https://github.com/facebook/immutable-js
|
|
1503
|
+
const IS_ITERABLE_SENTINEL = "@@__IMMUTABLE_ITERABLE__@@";
|
|
1504
|
+
const IS_LIST_SENTINEL = "@@__IMMUTABLE_LIST__@@";
|
|
1505
|
+
const IS_KEYED_SENTINEL = "@@__IMMUTABLE_KEYED__@@";
|
|
1506
|
+
const IS_MAP_SENTINEL = "@@__IMMUTABLE_MAP__@@";
|
|
1507
|
+
const IS_ORDERED_SENTINEL = "@@__IMMUTABLE_ORDERED__@@";
|
|
1508
|
+
const IS_RECORD_SENTINEL = "@@__IMMUTABLE_RECORD__@@";
|
|
1509
|
+
const IS_SEQ_SENTINEL = "@@__IMMUTABLE_SEQ__@@";
|
|
1510
|
+
const IS_SET_SENTINEL = "@@__IMMUTABLE_SET__@@";
|
|
1511
|
+
const IS_STACK_SENTINEL = "@@__IMMUTABLE_STACK__@@";
|
|
1512
|
+
const getImmutableName = (name)=>`Immutable.${name}`;
|
|
1513
|
+
const printAsLeaf = (name)=>`[${name}]`;
|
|
1514
|
+
const SPACE = " ";
|
|
1515
|
+
const LAZY = "…";
|
|
1516
|
+
function printImmutableEntries(val, config, indentation, depth, refs, printer, type) {
|
|
1517
|
+
return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : `${getImmutableName(type) + SPACE}{${printIteratorEntries(val.entries(), config, indentation, depth, refs, printer)}}`;
|
|
1518
|
+
}
|
|
1519
|
+
// Record has an entries method because it is a collection in immutable v3.
|
|
1520
|
+
// Return an iterator for Immutable Record from version v3 or v4.
|
|
1521
|
+
function getRecordEntries(val) {
|
|
1522
|
+
let i = 0;
|
|
1523
|
+
return {
|
|
1524
|
+
next () {
|
|
1525
|
+
if (i < val._keys.length) {
|
|
1526
|
+
const key = val._keys[i++];
|
|
1527
|
+
return {
|
|
1528
|
+
done: false,
|
|
1529
|
+
value: [
|
|
1530
|
+
key,
|
|
1531
|
+
val.get(key)
|
|
1532
|
+
]
|
|
1533
|
+
};
|
|
1534
|
+
}
|
|
1535
|
+
return {
|
|
1536
|
+
done: true,
|
|
1537
|
+
value: undefined
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1540
|
+
};
|
|
1541
|
+
}
|
|
1542
|
+
function printImmutableRecord(val, config, indentation, depth, refs, printer) {
|
|
1543
|
+
// _name property is defined only for an Immutable Record instance
|
|
1544
|
+
// which was constructed with a second optional descriptive name arg
|
|
1545
|
+
const name = getImmutableName(val._name || "Record");
|
|
1546
|
+
return ++depth > config.maxDepth ? printAsLeaf(name) : `${name + SPACE}{${printIteratorEntries(getRecordEntries(val), config, indentation, depth, refs, printer)}}`;
|
|
1547
|
+
}
|
|
1548
|
+
function printImmutableSeq(val, config, indentation, depth, refs, printer) {
|
|
1549
|
+
const name = getImmutableName("Seq");
|
|
1550
|
+
if (++depth > config.maxDepth) {
|
|
1551
|
+
return printAsLeaf(name);
|
|
1552
|
+
}
|
|
1553
|
+
if (val[IS_KEYED_SENTINEL]) {
|
|
1554
|
+
return `${name + SPACE}{${val._iter || val._object ? printIteratorEntries(val.entries(), config, indentation, depth, refs, printer) : LAZY}}`;
|
|
1555
|
+
}
|
|
1556
|
+
return `${name + SPACE}[${val._iter || val._array || val._collection || val._iterable ? printIteratorValues(val.values(), config, indentation, depth, refs, printer) : LAZY}]`;
|
|
1557
|
+
}
|
|
1558
|
+
function printImmutableValues(val, config, indentation, depth, refs, printer, type) {
|
|
1559
|
+
return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : `${getImmutableName(type) + SPACE}[${printIteratorValues(val.values(), config, indentation, depth, refs, printer)}]`;
|
|
1560
|
+
}
|
|
1561
|
+
const serialize$2 = (val, config, indentation, depth, refs, printer)=>{
|
|
1562
|
+
if (val[IS_MAP_SENTINEL]) {
|
|
1563
|
+
return printImmutableEntries(val, config, indentation, depth, refs, printer, val[IS_ORDERED_SENTINEL] ? "OrderedMap" : "Map");
|
|
1564
|
+
}
|
|
1565
|
+
if (val[IS_LIST_SENTINEL]) {
|
|
1566
|
+
return printImmutableValues(val, config, indentation, depth, refs, printer, "List");
|
|
1567
|
+
}
|
|
1568
|
+
if (val[IS_SET_SENTINEL]) {
|
|
1569
|
+
return printImmutableValues(val, config, indentation, depth, refs, printer, val[IS_ORDERED_SENTINEL] ? "OrderedSet" : "Set");
|
|
1570
|
+
}
|
|
1571
|
+
if (val[IS_STACK_SENTINEL]) {
|
|
1572
|
+
return printImmutableValues(val, config, indentation, depth, refs, printer, "Stack");
|
|
1573
|
+
}
|
|
1574
|
+
if (val[IS_SEQ_SENTINEL]) {
|
|
1575
|
+
return printImmutableSeq(val, config, indentation, depth, refs, printer);
|
|
1576
|
+
}
|
|
1577
|
+
// For compatibility with immutable v3 and v4, let record be the default.
|
|
1578
|
+
return printImmutableRecord(val, config, indentation, depth, refs, printer);
|
|
1579
|
+
};
|
|
1580
|
+
// Explicitly comparing sentinel properties to true avoids false positive
|
|
1581
|
+
// when mock identity-obj-proxy returns the key as the value for any key.
|
|
1582
|
+
const test$2 = (val)=>val && (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
|
|
1583
|
+
const plugin$2 = {
|
|
1584
|
+
serialize: serialize$2,
|
|
1585
|
+
test: test$2
|
|
1586
|
+
};
|
|
1587
|
+
function getDefaultExportFromCjs(x) {
|
|
1588
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
1589
|
+
}
|
|
1590
|
+
var reactIs$1 = {
|
|
1591
|
+
exports: {}
|
|
1592
|
+
};
|
|
1593
|
+
var reactIs_production = {};
|
|
1594
|
+
/**
|
|
1595
|
+
* @license React
|
|
1596
|
+
* react-is.production.js
|
|
1597
|
+
*
|
|
1598
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1599
|
+
*
|
|
1600
|
+
* This source code is licensed under the MIT license found in the
|
|
1601
|
+
* LICENSE file in the root directory of this source tree.
|
|
1602
|
+
*/ var hasRequiredReactIs_production;
|
|
1603
|
+
function requireReactIs_production() {
|
|
1604
|
+
if (hasRequiredReactIs_production) return reactIs_production;
|
|
1605
|
+
hasRequiredReactIs_production = 1;
|
|
1606
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference");
|
|
1607
|
+
function typeOf(object) {
|
|
1608
|
+
if ("object" === typeof object && null !== object) {
|
|
1609
|
+
var $$typeof = object.$$typeof;
|
|
1610
|
+
switch($$typeof){
|
|
1611
|
+
case REACT_ELEMENT_TYPE:
|
|
1612
|
+
switch(object = object.type, object){
|
|
1613
|
+
case REACT_FRAGMENT_TYPE:
|
|
1614
|
+
case REACT_PROFILER_TYPE:
|
|
1615
|
+
case REACT_STRICT_MODE_TYPE:
|
|
1616
|
+
case REACT_SUSPENSE_TYPE:
|
|
1617
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
1618
|
+
case REACT_VIEW_TRANSITION_TYPE:
|
|
1619
|
+
return object;
|
|
1620
|
+
default:
|
|
1621
|
+
switch(object = object && object.$$typeof, object){
|
|
1622
|
+
case REACT_CONTEXT_TYPE:
|
|
1623
|
+
case REACT_FORWARD_REF_TYPE:
|
|
1624
|
+
case REACT_LAZY_TYPE:
|
|
1625
|
+
case REACT_MEMO_TYPE:
|
|
1626
|
+
return object;
|
|
1627
|
+
case REACT_CONSUMER_TYPE:
|
|
1628
|
+
return object;
|
|
1629
|
+
default:
|
|
1630
|
+
return $$typeof;
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
case REACT_PORTAL_TYPE:
|
|
1634
|
+
return $$typeof;
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
reactIs_production.ContextConsumer = REACT_CONSUMER_TYPE;
|
|
1639
|
+
reactIs_production.ContextProvider = REACT_CONTEXT_TYPE;
|
|
1640
|
+
reactIs_production.Element = REACT_ELEMENT_TYPE;
|
|
1641
|
+
reactIs_production.ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
1642
|
+
reactIs_production.Fragment = REACT_FRAGMENT_TYPE;
|
|
1643
|
+
reactIs_production.Lazy = REACT_LAZY_TYPE;
|
|
1644
|
+
reactIs_production.Memo = REACT_MEMO_TYPE;
|
|
1645
|
+
reactIs_production.Portal = REACT_PORTAL_TYPE;
|
|
1646
|
+
reactIs_production.Profiler = REACT_PROFILER_TYPE;
|
|
1647
|
+
reactIs_production.StrictMode = REACT_STRICT_MODE_TYPE;
|
|
1648
|
+
reactIs_production.Suspense = REACT_SUSPENSE_TYPE;
|
|
1649
|
+
reactIs_production.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
|
|
1650
|
+
reactIs_production.isContextConsumer = function(object) {
|
|
1651
|
+
return typeOf(object) === REACT_CONSUMER_TYPE;
|
|
1652
|
+
};
|
|
1653
|
+
reactIs_production.isContextProvider = function(object) {
|
|
1654
|
+
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
1655
|
+
};
|
|
1656
|
+
reactIs_production.isElement = function(object) {
|
|
1657
|
+
return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
1658
|
+
};
|
|
1659
|
+
reactIs_production.isForwardRef = function(object) {
|
|
1660
|
+
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
1661
|
+
};
|
|
1662
|
+
reactIs_production.isFragment = function(object) {
|
|
1663
|
+
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
1664
|
+
};
|
|
1665
|
+
reactIs_production.isLazy = function(object) {
|
|
1666
|
+
return typeOf(object) === REACT_LAZY_TYPE;
|
|
1667
|
+
};
|
|
1668
|
+
reactIs_production.isMemo = function(object) {
|
|
1669
|
+
return typeOf(object) === REACT_MEMO_TYPE;
|
|
1670
|
+
};
|
|
1671
|
+
reactIs_production.isPortal = function(object) {
|
|
1672
|
+
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
1673
|
+
};
|
|
1674
|
+
reactIs_production.isProfiler = function(object) {
|
|
1675
|
+
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
1676
|
+
};
|
|
1677
|
+
reactIs_production.isStrictMode = function(object) {
|
|
1678
|
+
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
1679
|
+
};
|
|
1680
|
+
reactIs_production.isSuspense = function(object) {
|
|
1681
|
+
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
1682
|
+
};
|
|
1683
|
+
reactIs_production.isSuspenseList = function(object) {
|
|
1684
|
+
return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
|
|
1685
|
+
};
|
|
1686
|
+
reactIs_production.isValidElementType = function(type) {
|
|
1687
|
+
return "string" === typeof type || "function" === typeof type || type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || "object" === typeof type && null !== type && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_CONSUMER_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_CLIENT_REFERENCE || void 0 !== type.getModuleId) ? true : false;
|
|
1688
|
+
};
|
|
1689
|
+
reactIs_production.typeOf = typeOf;
|
|
1690
|
+
return reactIs_production;
|
|
1691
|
+
}
|
|
1692
|
+
var hasRequiredReactIs$1;
|
|
1693
|
+
function requireReactIs$1() {
|
|
1694
|
+
if (hasRequiredReactIs$1) return reactIs$1.exports;
|
|
1695
|
+
hasRequiredReactIs$1 = 1;
|
|
1696
|
+
{
|
|
1697
|
+
reactIs$1.exports = requireReactIs_production();
|
|
1698
|
+
}
|
|
1699
|
+
return reactIs$1.exports;
|
|
1700
|
+
}
|
|
1701
|
+
var reactIsExports$1 = requireReactIs$1();
|
|
1702
|
+
var index$1 = /*@__PURE__*/ getDefaultExportFromCjs(reactIsExports$1);
|
|
1703
|
+
var ReactIs19 = /*#__PURE__*/ _mergeNamespaces$1({
|
|
1704
|
+
__proto__: null,
|
|
1705
|
+
default: index$1
|
|
1706
|
+
}, [
|
|
1707
|
+
reactIsExports$1
|
|
1708
|
+
]);
|
|
1709
|
+
var reactIs = {
|
|
1710
|
+
exports: {}
|
|
1711
|
+
};
|
|
1712
|
+
var reactIs_production_min = {};
|
|
1713
|
+
/**
|
|
1714
|
+
* @license React
|
|
1715
|
+
* react-is.production.min.js
|
|
1716
|
+
*
|
|
1717
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
1718
|
+
*
|
|
1719
|
+
* This source code is licensed under the MIT license found in the
|
|
1720
|
+
* LICENSE file in the root directory of this source tree.
|
|
1721
|
+
*/ var hasRequiredReactIs_production_min;
|
|
1722
|
+
function requireReactIs_production_min() {
|
|
1723
|
+
if (hasRequiredReactIs_production_min) return reactIs_production_min;
|
|
1724
|
+
hasRequiredReactIs_production_min = 1;
|
|
1725
|
+
var b = Symbol.for("react.element"), c = Symbol.for("react.portal"), d = Symbol.for("react.fragment"), e = Symbol.for("react.strict_mode"), f = Symbol.for("react.profiler"), g = Symbol.for("react.provider"), h = Symbol.for("react.context"), k = Symbol.for("react.server_context"), l = Symbol.for("react.forward_ref"), m = Symbol.for("react.suspense"), n = Symbol.for("react.suspense_list"), p = Symbol.for("react.memo"), q = Symbol.for("react.lazy"), t = Symbol.for("react.offscreen"), u;
|
|
1726
|
+
u = Symbol.for("react.module.reference");
|
|
1727
|
+
function v(a) {
|
|
1728
|
+
if ("object" === typeof a && null !== a) {
|
|
1729
|
+
var r = a.$$typeof;
|
|
1730
|
+
switch(r){
|
|
1731
|
+
case b:
|
|
1732
|
+
switch(a = a.type, a){
|
|
1733
|
+
case d:
|
|
1734
|
+
case f:
|
|
1735
|
+
case e:
|
|
1736
|
+
case m:
|
|
1737
|
+
case n:
|
|
1738
|
+
return a;
|
|
1739
|
+
default:
|
|
1740
|
+
switch(a = a && a.$$typeof, a){
|
|
1741
|
+
case k:
|
|
1742
|
+
case h:
|
|
1743
|
+
case l:
|
|
1744
|
+
case q:
|
|
1745
|
+
case p:
|
|
1746
|
+
case g:
|
|
1747
|
+
return a;
|
|
1748
|
+
default:
|
|
1749
|
+
return r;
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
case c:
|
|
1753
|
+
return r;
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
reactIs_production_min.ContextConsumer = h;
|
|
1758
|
+
reactIs_production_min.ContextProvider = g;
|
|
1759
|
+
reactIs_production_min.Element = b;
|
|
1760
|
+
reactIs_production_min.ForwardRef = l;
|
|
1761
|
+
reactIs_production_min.Fragment = d;
|
|
1762
|
+
reactIs_production_min.Lazy = q;
|
|
1763
|
+
reactIs_production_min.Memo = p;
|
|
1764
|
+
reactIs_production_min.Portal = c;
|
|
1765
|
+
reactIs_production_min.Profiler = f;
|
|
1766
|
+
reactIs_production_min.StrictMode = e;
|
|
1767
|
+
reactIs_production_min.Suspense = m;
|
|
1768
|
+
reactIs_production_min.SuspenseList = n;
|
|
1769
|
+
reactIs_production_min.isAsyncMode = function() {
|
|
1770
|
+
return false;
|
|
1771
|
+
};
|
|
1772
|
+
reactIs_production_min.isConcurrentMode = function() {
|
|
1773
|
+
return false;
|
|
1774
|
+
};
|
|
1775
|
+
reactIs_production_min.isContextConsumer = function(a) {
|
|
1776
|
+
return v(a) === h;
|
|
1777
|
+
};
|
|
1778
|
+
reactIs_production_min.isContextProvider = function(a) {
|
|
1779
|
+
return v(a) === g;
|
|
1780
|
+
};
|
|
1781
|
+
reactIs_production_min.isElement = function(a) {
|
|
1782
|
+
return "object" === typeof a && null !== a && a.$$typeof === b;
|
|
1783
|
+
};
|
|
1784
|
+
reactIs_production_min.isForwardRef = function(a) {
|
|
1785
|
+
return v(a) === l;
|
|
1786
|
+
};
|
|
1787
|
+
reactIs_production_min.isFragment = function(a) {
|
|
1788
|
+
return v(a) === d;
|
|
1789
|
+
};
|
|
1790
|
+
reactIs_production_min.isLazy = function(a) {
|
|
1791
|
+
return v(a) === q;
|
|
1792
|
+
};
|
|
1793
|
+
reactIs_production_min.isMemo = function(a) {
|
|
1794
|
+
return v(a) === p;
|
|
1795
|
+
};
|
|
1796
|
+
reactIs_production_min.isPortal = function(a) {
|
|
1797
|
+
return v(a) === c;
|
|
1798
|
+
};
|
|
1799
|
+
reactIs_production_min.isProfiler = function(a) {
|
|
1800
|
+
return v(a) === f;
|
|
1801
|
+
};
|
|
1802
|
+
reactIs_production_min.isStrictMode = function(a) {
|
|
1803
|
+
return v(a) === e;
|
|
1804
|
+
};
|
|
1805
|
+
reactIs_production_min.isSuspense = function(a) {
|
|
1806
|
+
return v(a) === m;
|
|
1807
|
+
};
|
|
1808
|
+
reactIs_production_min.isSuspenseList = function(a) {
|
|
1809
|
+
return v(a) === n;
|
|
1810
|
+
};
|
|
1811
|
+
reactIs_production_min.isValidElementType = function(a) {
|
|
1812
|
+
return "string" === typeof a || "function" === typeof a || a === d || a === f || a === e || a === m || a === n || a === t || "object" === typeof a && null !== a && (a.$$typeof === q || a.$$typeof === p || a.$$typeof === g || a.$$typeof === h || a.$$typeof === l || a.$$typeof === u || void 0 !== a.getModuleId) ? true : false;
|
|
1813
|
+
};
|
|
1814
|
+
reactIs_production_min.typeOf = v;
|
|
1815
|
+
return reactIs_production_min;
|
|
1816
|
+
}
|
|
1817
|
+
var hasRequiredReactIs;
|
|
1818
|
+
function requireReactIs() {
|
|
1819
|
+
if (hasRequiredReactIs) return reactIs.exports;
|
|
1820
|
+
hasRequiredReactIs = 1;
|
|
1821
|
+
{
|
|
1822
|
+
reactIs.exports = requireReactIs_production_min();
|
|
1823
|
+
}
|
|
1824
|
+
return reactIs.exports;
|
|
1825
|
+
}
|
|
1826
|
+
var reactIsExports = requireReactIs();
|
|
1827
|
+
var index = /*@__PURE__*/ getDefaultExportFromCjs(reactIsExports);
|
|
1828
|
+
var ReactIs18 = /*#__PURE__*/ _mergeNamespaces$1({
|
|
1829
|
+
__proto__: null,
|
|
1830
|
+
default: index
|
|
1831
|
+
}, [
|
|
1832
|
+
reactIsExports
|
|
1833
|
+
]);
|
|
1834
|
+
const reactIsMethods = [
|
|
1835
|
+
"isAsyncMode",
|
|
1836
|
+
"isConcurrentMode",
|
|
1837
|
+
"isContextConsumer",
|
|
1838
|
+
"isContextProvider",
|
|
1839
|
+
"isElement",
|
|
1840
|
+
"isForwardRef",
|
|
1841
|
+
"isFragment",
|
|
1842
|
+
"isLazy",
|
|
1843
|
+
"isMemo",
|
|
1844
|
+
"isPortal",
|
|
1845
|
+
"isProfiler",
|
|
1846
|
+
"isStrictMode",
|
|
1847
|
+
"isSuspense",
|
|
1848
|
+
"isSuspenseList",
|
|
1849
|
+
"isValidElementType"
|
|
1850
|
+
];
|
|
1851
|
+
const ReactIs = Object.fromEntries(reactIsMethods.map((m)=>[
|
|
1852
|
+
m,
|
|
1853
|
+
(v)=>ReactIs18[m](v) || ReactIs19[m](v)
|
|
1854
|
+
]));
|
|
1855
|
+
// Given element.props.children, or subtree during recursive traversal,
|
|
1856
|
+
// return flattened array of children.
|
|
1857
|
+
function getChildren(arg, children = []) {
|
|
1858
|
+
if (Array.isArray(arg)) {
|
|
1859
|
+
for (const item of arg){
|
|
1860
|
+
getChildren(item, children);
|
|
1861
|
+
}
|
|
1862
|
+
} else if (arg != null && arg !== false && arg !== "") {
|
|
1863
|
+
children.push(arg);
|
|
1864
|
+
}
|
|
1865
|
+
return children;
|
|
1866
|
+
}
|
|
1867
|
+
function getType(element) {
|
|
1868
|
+
const type = element.type;
|
|
1869
|
+
if (typeof type === "string") {
|
|
1870
|
+
return type;
|
|
1871
|
+
}
|
|
1872
|
+
if (typeof type === "function") {
|
|
1873
|
+
return type.displayName || type.name || "Unknown";
|
|
1874
|
+
}
|
|
1875
|
+
if (ReactIs.isFragment(element)) {
|
|
1876
|
+
return "React.Fragment";
|
|
1877
|
+
}
|
|
1878
|
+
if (ReactIs.isSuspense(element)) {
|
|
1879
|
+
return "React.Suspense";
|
|
1880
|
+
}
|
|
1881
|
+
if (typeof type === "object" && type !== null) {
|
|
1882
|
+
if (ReactIs.isContextProvider(element)) {
|
|
1883
|
+
return "Context.Provider";
|
|
1884
|
+
}
|
|
1885
|
+
if (ReactIs.isContextConsumer(element)) {
|
|
1886
|
+
return "Context.Consumer";
|
|
1887
|
+
}
|
|
1888
|
+
if (ReactIs.isForwardRef(element)) {
|
|
1889
|
+
if (type.displayName) {
|
|
1890
|
+
return type.displayName;
|
|
1891
|
+
}
|
|
1892
|
+
const functionName = type.render.displayName || type.render.name || "";
|
|
1893
|
+
return functionName === "" ? "ForwardRef" : `ForwardRef(${functionName})`;
|
|
1894
|
+
}
|
|
1895
|
+
if (ReactIs.isMemo(element)) {
|
|
1896
|
+
const functionName = type.displayName || type.type.displayName || type.type.name || "";
|
|
1897
|
+
return functionName === "" ? "Memo" : `Memo(${functionName})`;
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
return "UNDEFINED";
|
|
1901
|
+
}
|
|
1902
|
+
function getPropKeys$1(element) {
|
|
1903
|
+
const { props } = element;
|
|
1904
|
+
return Object.keys(props).filter((key)=>key !== "children" && props[key] !== undefined).sort();
|
|
1905
|
+
}
|
|
1906
|
+
const serialize$1 = (element, config, indentation, depth, refs, printer)=>++depth > config.maxDepth ? printElementAsLeaf(getType(element), config) : printElement(getType(element), printProps(getPropKeys$1(element), element.props, config, indentation + config.indent, depth, refs, printer), printChildren(getChildren(element.props.children), config, indentation + config.indent, depth, refs, printer), config, indentation);
|
|
1907
|
+
const test$1 = (val)=>val != null && ReactIs.isElement(val);
|
|
1908
|
+
const plugin$1 = {
|
|
1909
|
+
serialize: serialize$1,
|
|
1910
|
+
test: test$1
|
|
1911
|
+
};
|
|
1912
|
+
const testSymbol = typeof Symbol === "function" && Symbol.for ? Symbol.for("react.test.json") : 245830487;
|
|
1913
|
+
function getPropKeys(object) {
|
|
1914
|
+
const { props } = object;
|
|
1915
|
+
return props ? Object.keys(props).filter((key)=>props[key] !== undefined).sort() : [];
|
|
1916
|
+
}
|
|
1917
|
+
const serialize = (object, config, indentation, depth, refs, printer)=>++depth > config.maxDepth ? printElementAsLeaf(object.type, config) : printElement(object.type, object.props ? printProps(getPropKeys(object), object.props, config, indentation + config.indent, depth, refs, printer) : "", object.children ? printChildren(object.children, config, indentation + config.indent, depth, refs, printer) : "", config, indentation);
|
|
1918
|
+
const test$6 = (val)=>val && val.$$typeof === testSymbol;
|
|
1919
|
+
const plugin = {
|
|
1920
|
+
serialize,
|
|
1921
|
+
test: test$6
|
|
1922
|
+
};
|
|
1923
|
+
const toString$1 = Object.prototype.toString;
|
|
1924
|
+
const toISOString = Date.prototype.toISOString;
|
|
1925
|
+
const errorToString = Error.prototype.toString;
|
|
1926
|
+
const regExpToString = RegExp.prototype.toString;
|
|
1927
|
+
/**
|
|
1928
|
+
* Explicitly comparing typeof constructor to function avoids undefined as name
|
|
1929
|
+
* when mock identity-obj-proxy returns the key as the value for any key.
|
|
1930
|
+
*/ function getConstructorName(val) {
|
|
1931
|
+
return typeof val.constructor === "function" && val.constructor.name || "Object";
|
|
1932
|
+
}
|
|
1933
|
+
/** Is val is equal to global window object? Works even if it does not exist :) */ function isWindow(val) {
|
|
1934
|
+
return typeof window !== "undefined" && val === window;
|
|
1935
|
+
}
|
|
1936
|
+
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
|
1937
|
+
const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
|
|
1938
|
+
const NEWLINE_REGEXP = /\n/g;
|
|
1939
|
+
class PrettyFormatPluginError extends Error {
|
|
1940
|
+
constructor(message, stack){
|
|
1941
|
+
super(message);
|
|
1942
|
+
this.stack = stack;
|
|
1943
|
+
this.name = this.constructor.name;
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
function isToStringedArrayType(toStringed) {
|
|
1947
|
+
return toStringed === "[object Array]" || toStringed === "[object ArrayBuffer]" || toStringed === "[object DataView]" || toStringed === "[object Float32Array]" || toStringed === "[object Float64Array]" || toStringed === "[object Int8Array]" || toStringed === "[object Int16Array]" || toStringed === "[object Int32Array]" || toStringed === "[object Uint8Array]" || toStringed === "[object Uint8ClampedArray]" || toStringed === "[object Uint16Array]" || toStringed === "[object Uint32Array]";
|
|
1948
|
+
}
|
|
1949
|
+
function printNumber(val) {
|
|
1950
|
+
return Object.is(val, -0) ? "-0" : String(val);
|
|
1951
|
+
}
|
|
1952
|
+
function printBigInt(val) {
|
|
1953
|
+
return String(`${val}n`);
|
|
1954
|
+
}
|
|
1955
|
+
function printFunction(val, printFunctionName) {
|
|
1956
|
+
if (!printFunctionName) {
|
|
1957
|
+
return "[Function]";
|
|
1958
|
+
}
|
|
1959
|
+
return `[Function ${val.name || "anonymous"}]`;
|
|
1960
|
+
}
|
|
1961
|
+
function printSymbol(val) {
|
|
1962
|
+
return String(val).replace(SYMBOL_REGEXP, "Symbol($1)");
|
|
1963
|
+
}
|
|
1964
|
+
function printError(val) {
|
|
1965
|
+
return `[${errorToString.call(val)}]`;
|
|
1966
|
+
}
|
|
1967
|
+
/**
|
|
1968
|
+
* The first port of call for printing an object, handles most of the
|
|
1969
|
+
* data-types in JS.
|
|
1970
|
+
*/ function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
|
|
1971
|
+
if (val === true || val === false) {
|
|
1972
|
+
return `${val}`;
|
|
1973
|
+
}
|
|
1974
|
+
if (val === undefined) {
|
|
1975
|
+
return "undefined";
|
|
1976
|
+
}
|
|
1977
|
+
if (val === null) {
|
|
1978
|
+
return "null";
|
|
1979
|
+
}
|
|
1980
|
+
const typeOf = typeof val;
|
|
1981
|
+
if (typeOf === "number") {
|
|
1982
|
+
return printNumber(val);
|
|
1983
|
+
}
|
|
1984
|
+
if (typeOf === "bigint") {
|
|
1985
|
+
return printBigInt(val);
|
|
1986
|
+
}
|
|
1987
|
+
if (typeOf === "string") {
|
|
1988
|
+
if (escapeString) {
|
|
1989
|
+
return `"${val.replaceAll(/"|\\/g, "\\$&")}"`;
|
|
1990
|
+
}
|
|
1991
|
+
return `"${val}"`;
|
|
1992
|
+
}
|
|
1993
|
+
if (typeOf === "function") {
|
|
1994
|
+
return printFunction(val, printFunctionName);
|
|
1995
|
+
}
|
|
1996
|
+
if (typeOf === "symbol") {
|
|
1997
|
+
return printSymbol(val);
|
|
1998
|
+
}
|
|
1999
|
+
const toStringed = toString$1.call(val);
|
|
2000
|
+
if (toStringed === "[object WeakMap]") {
|
|
2001
|
+
return "WeakMap {}";
|
|
2002
|
+
}
|
|
2003
|
+
if (toStringed === "[object WeakSet]") {
|
|
2004
|
+
return "WeakSet {}";
|
|
2005
|
+
}
|
|
2006
|
+
if (toStringed === "[object Function]" || toStringed === "[object GeneratorFunction]") {
|
|
2007
|
+
return printFunction(val, printFunctionName);
|
|
2008
|
+
}
|
|
2009
|
+
if (toStringed === "[object Symbol]") {
|
|
2010
|
+
return printSymbol(val);
|
|
2011
|
+
}
|
|
2012
|
+
if (toStringed === "[object Date]") {
|
|
2013
|
+
return Number.isNaN(+val) ? "Date { NaN }" : toISOString.call(val);
|
|
2014
|
+
}
|
|
2015
|
+
if (toStringed === "[object Error]") {
|
|
2016
|
+
return printError(val);
|
|
2017
|
+
}
|
|
2018
|
+
if (toStringed === "[object RegExp]") {
|
|
2019
|
+
if (escapeRegex) {
|
|
2020
|
+
// https://github.com/benjamingr/RegExp.escape/blob/main/polyfill.js
|
|
2021
|
+
return regExpToString.call(val).replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&");
|
|
2022
|
+
}
|
|
2023
|
+
return regExpToString.call(val);
|
|
2024
|
+
}
|
|
2025
|
+
if (val instanceof Error) {
|
|
2026
|
+
return printError(val);
|
|
2027
|
+
}
|
|
2028
|
+
return null;
|
|
2029
|
+
}
|
|
2030
|
+
/**
|
|
2031
|
+
* Handles more complex objects ( such as objects with circular references.
|
|
2032
|
+
* maps and sets etc )
|
|
2033
|
+
*/ function printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON) {
|
|
2034
|
+
if (refs.includes(val)) {
|
|
2035
|
+
return "[Circular]";
|
|
2036
|
+
}
|
|
2037
|
+
refs = [
|
|
2038
|
+
...refs
|
|
2039
|
+
];
|
|
2040
|
+
refs.push(val);
|
|
2041
|
+
const hitMaxDepth = ++depth > config.maxDepth;
|
|
2042
|
+
const min = config.min;
|
|
2043
|
+
if (config.callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === "function" && !hasCalledToJSON) {
|
|
2044
|
+
return printer(val.toJSON(), config, indentation, depth, refs, true);
|
|
2045
|
+
}
|
|
2046
|
+
const toStringed = toString$1.call(val);
|
|
2047
|
+
if (toStringed === "[object Arguments]") {
|
|
2048
|
+
return hitMaxDepth ? "[Arguments]" : `${min ? "" : "Arguments "}[${printListItems(val, config, indentation, depth, refs, printer)}]`;
|
|
2049
|
+
}
|
|
2050
|
+
if (isToStringedArrayType(toStringed)) {
|
|
2051
|
+
return hitMaxDepth ? `[${val.constructor.name}]` : `${min ? "" : !config.printBasicPrototype && val.constructor.name === "Array" ? "" : `${val.constructor.name} `}[${printListItems(val, config, indentation, depth, refs, printer)}]`;
|
|
2052
|
+
}
|
|
2053
|
+
if (toStringed === "[object Map]") {
|
|
2054
|
+
return hitMaxDepth ? "[Map]" : `Map {${printIteratorEntries(val.entries(), config, indentation, depth, refs, printer, " => ")}}`;
|
|
2055
|
+
}
|
|
2056
|
+
if (toStringed === "[object Set]") {
|
|
2057
|
+
return hitMaxDepth ? "[Set]" : `Set {${printIteratorValues(val.values(), config, indentation, depth, refs, printer)}}`;
|
|
2058
|
+
}
|
|
2059
|
+
// Avoid failure to serialize global window object in jsdom test environment.
|
|
2060
|
+
// For example, not even relevant if window is prop of React element.
|
|
2061
|
+
return hitMaxDepth || isWindow(val) ? `[${getConstructorName(val)}]` : `${min ? "" : !config.printBasicPrototype && getConstructorName(val) === "Object" ? "" : `${getConstructorName(val)} `}{${printObjectProperties(val, config, indentation, depth, refs, printer)}}`;
|
|
2062
|
+
}
|
|
2063
|
+
function isNewPlugin(plugin) {
|
|
2064
|
+
return plugin.serialize != null;
|
|
2065
|
+
}
|
|
2066
|
+
function printPlugin(plugin, val, config, indentation, depth, refs) {
|
|
2067
|
+
let printed;
|
|
2068
|
+
try {
|
|
2069
|
+
printed = isNewPlugin(plugin) ? plugin.serialize(val, config, indentation, depth, refs, printer) : plugin.print(val, (valChild)=>printer(valChild, config, indentation, depth, refs), (str)=>{
|
|
2070
|
+
const indentationNext = indentation + config.indent;
|
|
2071
|
+
return indentationNext + str.replaceAll(NEWLINE_REGEXP, `\n${indentationNext}`);
|
|
2072
|
+
}, {
|
|
2073
|
+
edgeSpacing: config.spacingOuter,
|
|
2074
|
+
min: config.min,
|
|
2075
|
+
spacing: config.spacingInner
|
|
2076
|
+
}, config.colors);
|
|
2077
|
+
} catch (error) {
|
|
2078
|
+
throw new PrettyFormatPluginError(error.message, error.stack);
|
|
2079
|
+
}
|
|
2080
|
+
if (typeof printed !== "string") {
|
|
2081
|
+
throw new TypeError(`pretty-format: Plugin must return type "string" but instead returned "${typeof printed}".`);
|
|
2082
|
+
}
|
|
2083
|
+
return printed;
|
|
2084
|
+
}
|
|
2085
|
+
function findPlugin(plugins, val) {
|
|
2086
|
+
for (const plugin of plugins){
|
|
2087
|
+
try {
|
|
2088
|
+
if (plugin.test(val)) {
|
|
2089
|
+
return plugin;
|
|
2090
|
+
}
|
|
2091
|
+
} catch (error) {
|
|
2092
|
+
throw new PrettyFormatPluginError(error.message, error.stack);
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
return null;
|
|
2096
|
+
}
|
|
2097
|
+
function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
|
|
2098
|
+
const plugin = findPlugin(config.plugins, val);
|
|
2099
|
+
if (plugin !== null) {
|
|
2100
|
+
return printPlugin(plugin, val, config, indentation, depth, refs);
|
|
2101
|
+
}
|
|
2102
|
+
const basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex, config.escapeString);
|
|
2103
|
+
if (basicResult !== null) {
|
|
2104
|
+
return basicResult;
|
|
2105
|
+
}
|
|
2106
|
+
return printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON);
|
|
2107
|
+
}
|
|
2108
|
+
const DEFAULT_THEME = {
|
|
2109
|
+
comment: "gray",
|
|
2110
|
+
content: "reset",
|
|
2111
|
+
prop: "yellow",
|
|
2112
|
+
tag: "cyan",
|
|
2113
|
+
value: "green"
|
|
2114
|
+
};
|
|
2115
|
+
const DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME);
|
|
2116
|
+
const DEFAULT_OPTIONS = {
|
|
2117
|
+
callToJSON: true,
|
|
2118
|
+
compareKeys: undefined,
|
|
2119
|
+
escapeRegex: false,
|
|
2120
|
+
escapeString: true,
|
|
2121
|
+
highlight: false,
|
|
2122
|
+
indent: 2,
|
|
2123
|
+
maxDepth: Number.POSITIVE_INFINITY,
|
|
2124
|
+
maxWidth: Number.POSITIVE_INFINITY,
|
|
2125
|
+
min: false,
|
|
2126
|
+
plugins: [],
|
|
2127
|
+
printBasicPrototype: true,
|
|
2128
|
+
printFunctionName: true,
|
|
2129
|
+
printShadowRoot: true,
|
|
2130
|
+
theme: DEFAULT_THEME
|
|
2131
|
+
};
|
|
2132
|
+
function validateOptions(options) {
|
|
2133
|
+
for (const key of Object.keys(options)){
|
|
2134
|
+
if (!Object.hasOwn(DEFAULT_OPTIONS, key)) {
|
|
2135
|
+
throw new Error(`pretty-format: Unknown option "${key}".`);
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
if (options.min && options.indent !== undefined && options.indent !== 0) {
|
|
2139
|
+
throw new Error("pretty-format: Options \"min\" and \"indent\" cannot be used together.");
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
function getColorsHighlight() {
|
|
2143
|
+
return DEFAULT_THEME_KEYS.reduce((colors, key)=>{
|
|
2144
|
+
const value = DEFAULT_THEME[key];
|
|
2145
|
+
const color = value && C[value];
|
|
2146
|
+
if (color && typeof color.close === "string" && typeof color.open === "string") {
|
|
2147
|
+
colors[key] = color;
|
|
2148
|
+
} else {
|
|
2149
|
+
throw new Error(`pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`);
|
|
2150
|
+
}
|
|
2151
|
+
return colors;
|
|
2152
|
+
}, Object.create(null));
|
|
2153
|
+
}
|
|
2154
|
+
function getColorsEmpty() {
|
|
2155
|
+
return DEFAULT_THEME_KEYS.reduce((colors, key)=>{
|
|
2156
|
+
colors[key] = {
|
|
2157
|
+
close: "",
|
|
2158
|
+
open: ""
|
|
2159
|
+
};
|
|
2160
|
+
return colors;
|
|
2161
|
+
}, Object.create(null));
|
|
2162
|
+
}
|
|
2163
|
+
function getPrintFunctionName(options) {
|
|
2164
|
+
return options?.printFunctionName ?? DEFAULT_OPTIONS.printFunctionName;
|
|
2165
|
+
}
|
|
2166
|
+
function getEscapeRegex(options) {
|
|
2167
|
+
return options?.escapeRegex ?? DEFAULT_OPTIONS.escapeRegex;
|
|
2168
|
+
}
|
|
2169
|
+
function getEscapeString(options) {
|
|
2170
|
+
return options?.escapeString ?? DEFAULT_OPTIONS.escapeString;
|
|
2171
|
+
}
|
|
2172
|
+
function getConfig(options) {
|
|
2173
|
+
return {
|
|
2174
|
+
callToJSON: options?.callToJSON ?? DEFAULT_OPTIONS.callToJSON,
|
|
2175
|
+
colors: options?.highlight ? getColorsHighlight() : getColorsEmpty(),
|
|
2176
|
+
compareKeys: typeof options?.compareKeys === "function" || options?.compareKeys === null ? options.compareKeys : DEFAULT_OPTIONS.compareKeys,
|
|
2177
|
+
escapeRegex: getEscapeRegex(options),
|
|
2178
|
+
escapeString: getEscapeString(options),
|
|
2179
|
+
indent: options?.min ? "" : createIndent(options?.indent ?? DEFAULT_OPTIONS.indent),
|
|
2180
|
+
maxDepth: options?.maxDepth ?? DEFAULT_OPTIONS.maxDepth,
|
|
2181
|
+
maxWidth: options?.maxWidth ?? DEFAULT_OPTIONS.maxWidth,
|
|
2182
|
+
min: options?.min ?? DEFAULT_OPTIONS.min,
|
|
2183
|
+
plugins: options?.plugins ?? DEFAULT_OPTIONS.plugins,
|
|
2184
|
+
printBasicPrototype: options?.printBasicPrototype ?? true,
|
|
2185
|
+
printFunctionName: getPrintFunctionName(options),
|
|
2186
|
+
printShadowRoot: options?.printShadowRoot ?? true,
|
|
2187
|
+
spacingInner: options?.min ? " " : "\n",
|
|
2188
|
+
spacingOuter: options?.min ? "" : "\n"
|
|
2189
|
+
};
|
|
2190
|
+
}
|
|
2191
|
+
function createIndent(indent) {
|
|
2192
|
+
return Array.from({
|
|
2193
|
+
length: indent + 1
|
|
2194
|
+
}).join(" ");
|
|
2195
|
+
}
|
|
2196
|
+
/**
|
|
2197
|
+
* Returns a presentation string of your `val` object
|
|
2198
|
+
* @param val any potential JavaScript object
|
|
2199
|
+
* @param options Custom settings
|
|
2200
|
+
*/ function format$1(val, options) {
|
|
2201
|
+
if (options) {
|
|
2202
|
+
validateOptions(options);
|
|
2203
|
+
if (options.plugins) {
|
|
2204
|
+
const plugin = findPlugin(options.plugins, val);
|
|
2205
|
+
if (plugin !== null) {
|
|
2206
|
+
return printPlugin(plugin, val, getConfig(options), "", 0, []);
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
const basicResult = printBasicValue(val, getPrintFunctionName(options), getEscapeRegex(options), getEscapeString(options));
|
|
2211
|
+
if (basicResult !== null) {
|
|
2212
|
+
return basicResult;
|
|
2213
|
+
}
|
|
2214
|
+
return printComplexValue(val, getConfig(options), "", 0, []);
|
|
2215
|
+
}
|
|
2216
|
+
const plugins = {
|
|
2217
|
+
AsymmetricMatcher: plugin$5,
|
|
2218
|
+
DOMCollection: plugin$4,
|
|
2219
|
+
DOMElement: plugin$3,
|
|
2220
|
+
Immutable: plugin$2,
|
|
2221
|
+
ReactElement: plugin$1,
|
|
2222
|
+
ReactTestComponent: plugin};
|
|
2223
|
+
|
|
2224
|
+
const ansiColors = {
|
|
2225
|
+
bold: [
|
|
2226
|
+
'1',
|
|
2227
|
+
'22'
|
|
2228
|
+
],
|
|
2229
|
+
dim: [
|
|
2230
|
+
'2',
|
|
2231
|
+
'22'
|
|
2232
|
+
],
|
|
2233
|
+
italic: [
|
|
2234
|
+
'3',
|
|
2235
|
+
'23'
|
|
2236
|
+
],
|
|
2237
|
+
underline: [
|
|
2238
|
+
'4',
|
|
2239
|
+
'24'
|
|
2240
|
+
],
|
|
2241
|
+
// 5 & 6 are blinking
|
|
2242
|
+
inverse: [
|
|
2243
|
+
'7',
|
|
2244
|
+
'27'
|
|
2245
|
+
],
|
|
2246
|
+
hidden: [
|
|
2247
|
+
'8',
|
|
2248
|
+
'28'
|
|
2249
|
+
],
|
|
2250
|
+
strike: [
|
|
2251
|
+
'9',
|
|
2252
|
+
'29'
|
|
2253
|
+
],
|
|
2254
|
+
// 10-20 are fonts
|
|
2255
|
+
// 21-29 are resets for 1-9
|
|
2256
|
+
black: [
|
|
2257
|
+
'30',
|
|
2258
|
+
'39'
|
|
2259
|
+
],
|
|
2260
|
+
red: [
|
|
2261
|
+
'31',
|
|
2262
|
+
'39'
|
|
2263
|
+
],
|
|
2264
|
+
green: [
|
|
2265
|
+
'32',
|
|
2266
|
+
'39'
|
|
2267
|
+
],
|
|
2268
|
+
yellow: [
|
|
2269
|
+
'33',
|
|
2270
|
+
'39'
|
|
2271
|
+
],
|
|
2272
|
+
blue: [
|
|
2273
|
+
'34',
|
|
2274
|
+
'39'
|
|
2275
|
+
],
|
|
2276
|
+
magenta: [
|
|
2277
|
+
'35',
|
|
2278
|
+
'39'
|
|
2279
|
+
],
|
|
2280
|
+
cyan: [
|
|
2281
|
+
'36',
|
|
2282
|
+
'39'
|
|
2283
|
+
],
|
|
2284
|
+
white: [
|
|
2285
|
+
'37',
|
|
2286
|
+
'39'
|
|
2287
|
+
],
|
|
2288
|
+
brightblack: [
|
|
2289
|
+
'30;1',
|
|
2290
|
+
'39'
|
|
2291
|
+
],
|
|
2292
|
+
brightred: [
|
|
2293
|
+
'31;1',
|
|
2294
|
+
'39'
|
|
2295
|
+
],
|
|
2296
|
+
brightgreen: [
|
|
2297
|
+
'32;1',
|
|
2298
|
+
'39'
|
|
2299
|
+
],
|
|
2300
|
+
brightyellow: [
|
|
2301
|
+
'33;1',
|
|
2302
|
+
'39'
|
|
2303
|
+
],
|
|
2304
|
+
brightblue: [
|
|
2305
|
+
'34;1',
|
|
2306
|
+
'39'
|
|
2307
|
+
],
|
|
2308
|
+
brightmagenta: [
|
|
2309
|
+
'35;1',
|
|
2310
|
+
'39'
|
|
2311
|
+
],
|
|
2312
|
+
brightcyan: [
|
|
2313
|
+
'36;1',
|
|
2314
|
+
'39'
|
|
2315
|
+
],
|
|
2316
|
+
brightwhite: [
|
|
2317
|
+
'37;1',
|
|
2318
|
+
'39'
|
|
2319
|
+
],
|
|
2320
|
+
grey: [
|
|
2321
|
+
'90',
|
|
2322
|
+
'39'
|
|
2323
|
+
]
|
|
2324
|
+
};
|
|
2325
|
+
const styles = {
|
|
2326
|
+
special: 'cyan',
|
|
2327
|
+
number: 'yellow',
|
|
2328
|
+
bigint: 'yellow',
|
|
2329
|
+
boolean: 'yellow',
|
|
2330
|
+
undefined: 'grey',
|
|
2331
|
+
null: 'bold',
|
|
2332
|
+
string: 'green',
|
|
2333
|
+
symbol: 'green',
|
|
2334
|
+
date: 'magenta',
|
|
2335
|
+
regexp: 'red'
|
|
2336
|
+
};
|
|
2337
|
+
const truncator = '…';
|
|
2338
|
+
function colorise(value, styleType) {
|
|
2339
|
+
const color = ansiColors[styles[styleType]] || ansiColors[styleType] || '';
|
|
2340
|
+
if (!color) {
|
|
2341
|
+
return String(value);
|
|
2342
|
+
}
|
|
2343
|
+
return `\u001b[${color[0]}m${String(value)}\u001b[${color[1]}m`;
|
|
2344
|
+
}
|
|
2345
|
+
function normaliseOptions({ showHidden = false, depth = 2, colors = false, customInspect = true, showProxy = false, maxArrayLength = Infinity, breakLength = Infinity, seen = [], // eslint-disable-next-line no-shadow
|
|
2346
|
+
truncate = Infinity, stylize = String } = {}, inspect) {
|
|
2347
|
+
const options = {
|
|
2348
|
+
showHidden: Boolean(showHidden),
|
|
2349
|
+
depth: Number(depth),
|
|
2350
|
+
colors: Boolean(colors),
|
|
2351
|
+
customInspect: Boolean(customInspect),
|
|
2352
|
+
showProxy: Boolean(showProxy),
|
|
2353
|
+
maxArrayLength: Number(maxArrayLength),
|
|
2354
|
+
breakLength: Number(breakLength),
|
|
2355
|
+
truncate: Number(truncate),
|
|
2356
|
+
seen,
|
|
2357
|
+
inspect,
|
|
2358
|
+
stylize
|
|
2359
|
+
};
|
|
2360
|
+
if (options.colors) {
|
|
2361
|
+
options.stylize = colorise;
|
|
2362
|
+
}
|
|
2363
|
+
return options;
|
|
2364
|
+
}
|
|
2365
|
+
function isHighSurrogate(char) {
|
|
2366
|
+
return char >= '\ud800' && char <= '\udbff';
|
|
2367
|
+
}
|
|
2368
|
+
function truncate(string, length, tail = truncator) {
|
|
2369
|
+
string = String(string);
|
|
2370
|
+
const tailLength = tail.length;
|
|
2371
|
+
const stringLength = string.length;
|
|
2372
|
+
if (tailLength > length && stringLength > tailLength) {
|
|
2373
|
+
return tail;
|
|
2374
|
+
}
|
|
2375
|
+
if (stringLength > length && stringLength > tailLength) {
|
|
2376
|
+
let end = length - tailLength;
|
|
2377
|
+
if (end > 0 && isHighSurrogate(string[end - 1])) {
|
|
2378
|
+
end = end - 1;
|
|
2379
|
+
}
|
|
2380
|
+
return `${string.slice(0, end)}${tail}`;
|
|
2381
|
+
}
|
|
2382
|
+
return string;
|
|
2383
|
+
}
|
|
2384
|
+
// eslint-disable-next-line complexity
|
|
2385
|
+
function inspectList(list, options, inspectItem, separator = ', ') {
|
|
2386
|
+
inspectItem = inspectItem || options.inspect;
|
|
2387
|
+
const size = list.length;
|
|
2388
|
+
if (size === 0) return '';
|
|
2389
|
+
const originalLength = options.truncate;
|
|
2390
|
+
let output = '';
|
|
2391
|
+
let peek = '';
|
|
2392
|
+
let truncated = '';
|
|
2393
|
+
for(let i = 0; i < size; i += 1){
|
|
2394
|
+
const last = i + 1 === list.length;
|
|
2395
|
+
const secondToLast = i + 2 === list.length;
|
|
2396
|
+
truncated = `${truncator}(${list.length - i})`;
|
|
2397
|
+
const value = list[i];
|
|
2398
|
+
// If there is more than one remaining we need to account for a separator of `, `
|
|
2399
|
+
options.truncate = originalLength - output.length - (last ? 0 : separator.length);
|
|
2400
|
+
const string = peek || inspectItem(value, options) + (last ? '' : separator);
|
|
2401
|
+
const nextLength = output.length + string.length;
|
|
2402
|
+
const truncatedLength = nextLength + truncated.length;
|
|
2403
|
+
// If this is the last element, and adding it would
|
|
2404
|
+
// take us over length, but adding the truncator wouldn't - then break now
|
|
2405
|
+
if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) {
|
|
2406
|
+
break;
|
|
2407
|
+
}
|
|
2408
|
+
// If this isn't the last or second to last element to scan,
|
|
2409
|
+
// but the string is already over length then break here
|
|
2410
|
+
if (!last && !secondToLast && truncatedLength > originalLength) {
|
|
2411
|
+
break;
|
|
2412
|
+
}
|
|
2413
|
+
// Peek at the next string to determine if we should
|
|
2414
|
+
// break early before adding this item to the output
|
|
2415
|
+
peek = last ? '' : inspectItem(list[i + 1], options) + (secondToLast ? '' : separator);
|
|
2416
|
+
// If we have one element left, but this element and
|
|
2417
|
+
// the next takes over length, the break early
|
|
2418
|
+
if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) {
|
|
2419
|
+
break;
|
|
2420
|
+
}
|
|
2421
|
+
output += string;
|
|
2422
|
+
// If the next element takes us to length -
|
|
2423
|
+
// but there are more after that, then we should truncate now
|
|
2424
|
+
if (!last && !secondToLast && nextLength + peek.length >= originalLength) {
|
|
2425
|
+
truncated = `${truncator}(${list.length - i - 1})`;
|
|
2426
|
+
break;
|
|
2427
|
+
}
|
|
2428
|
+
truncated = '';
|
|
2429
|
+
}
|
|
2430
|
+
return `${output}${truncated}`;
|
|
2431
|
+
}
|
|
2432
|
+
function quoteComplexKey(key) {
|
|
2433
|
+
if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) {
|
|
2434
|
+
return key;
|
|
2435
|
+
}
|
|
2436
|
+
return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
|
|
2437
|
+
}
|
|
2438
|
+
function inspectProperty([key, value], options) {
|
|
2439
|
+
options.truncate -= 2;
|
|
2440
|
+
if (typeof key === 'string') {
|
|
2441
|
+
key = quoteComplexKey(key);
|
|
2442
|
+
} else if (typeof key !== 'number') {
|
|
2443
|
+
key = `[${options.inspect(key, options)}]`;
|
|
2444
|
+
}
|
|
2445
|
+
options.truncate -= key.length;
|
|
2446
|
+
value = options.inspect(value, options);
|
|
2447
|
+
return `${key}: ${value}`;
|
|
2448
|
+
}
|
|
2449
|
+
function inspectArray(array, options) {
|
|
2450
|
+
// Object.keys will always output the Array indices first, so we can slice by
|
|
2451
|
+
// `array.length` to get non-index properties
|
|
2452
|
+
const nonIndexProperties = Object.keys(array).slice(array.length);
|
|
2453
|
+
if (!array.length && !nonIndexProperties.length) return '[]';
|
|
2454
|
+
options.truncate -= 4;
|
|
2455
|
+
const listContents = inspectList(array, options);
|
|
2456
|
+
options.truncate -= listContents.length;
|
|
2457
|
+
let propertyContents = '';
|
|
2458
|
+
if (nonIndexProperties.length) {
|
|
2459
|
+
propertyContents = inspectList(nonIndexProperties.map((key)=>[
|
|
2460
|
+
key,
|
|
2461
|
+
array[key]
|
|
2462
|
+
]), options, inspectProperty);
|
|
2463
|
+
}
|
|
2464
|
+
return `[ ${listContents}${propertyContents ? `, ${propertyContents}` : ''} ]`;
|
|
2465
|
+
}
|
|
2466
|
+
const getArrayName = (array)=>{
|
|
2467
|
+
// We need to special case Node.js' Buffers, which report to be Uint8Array
|
|
2468
|
+
// @ts-ignore
|
|
2469
|
+
if (typeof Buffer === 'function' && array instanceof Buffer) {
|
|
2470
|
+
return 'Buffer';
|
|
2471
|
+
}
|
|
2472
|
+
if (array[Symbol.toStringTag]) {
|
|
2473
|
+
return array[Symbol.toStringTag];
|
|
2474
|
+
}
|
|
2475
|
+
return array.constructor.name;
|
|
2476
|
+
};
|
|
2477
|
+
function inspectTypedArray(array, options) {
|
|
2478
|
+
const name = getArrayName(array);
|
|
2479
|
+
options.truncate -= name.length + 4;
|
|
2480
|
+
// Object.keys will always output the Array indices first, so we can slice by
|
|
2481
|
+
// `array.length` to get non-index properties
|
|
2482
|
+
const nonIndexProperties = Object.keys(array).slice(array.length);
|
|
2483
|
+
if (!array.length && !nonIndexProperties.length) return `${name}[]`;
|
|
2484
|
+
// As we know TypedArrays only contain Unsigned Integers, we can skip inspecting each one and simply
|
|
2485
|
+
// stylise the toString() value of them
|
|
2486
|
+
let output = '';
|
|
2487
|
+
for(let i = 0; i < array.length; i++){
|
|
2488
|
+
const string = `${options.stylize(truncate(array[i], options.truncate), 'number')}${i === array.length - 1 ? '' : ', '}`;
|
|
2489
|
+
options.truncate -= string.length;
|
|
2490
|
+
if (array[i] !== array.length && options.truncate <= 3) {
|
|
2491
|
+
output += `${truncator}(${array.length - array[i] + 1})`;
|
|
2492
|
+
break;
|
|
2493
|
+
}
|
|
2494
|
+
output += string;
|
|
2495
|
+
}
|
|
2496
|
+
let propertyContents = '';
|
|
2497
|
+
if (nonIndexProperties.length) {
|
|
2498
|
+
propertyContents = inspectList(nonIndexProperties.map((key)=>[
|
|
2499
|
+
key,
|
|
2500
|
+
array[key]
|
|
2501
|
+
]), options, inspectProperty);
|
|
2502
|
+
}
|
|
2503
|
+
return `${name}[ ${output}${propertyContents ? `, ${propertyContents}` : ''} ]`;
|
|
2504
|
+
}
|
|
2505
|
+
function inspectDate(dateObject, options) {
|
|
2506
|
+
const stringRepresentation = dateObject.toJSON();
|
|
2507
|
+
if (stringRepresentation === null) {
|
|
2508
|
+
return 'Invalid Date';
|
|
2509
|
+
}
|
|
2510
|
+
const split = stringRepresentation.split('T');
|
|
2511
|
+
const date = split[0];
|
|
2512
|
+
// If we need to - truncate the time portion, but never the date
|
|
2513
|
+
return options.stylize(`${date}T${truncate(split[1], options.truncate - date.length - 1)}`, 'date');
|
|
2514
|
+
}
|
|
2515
|
+
function inspectFunction(func, options) {
|
|
2516
|
+
const functionType = func[Symbol.toStringTag] || 'Function';
|
|
2517
|
+
const name = func.name;
|
|
2518
|
+
if (!name) {
|
|
2519
|
+
return options.stylize(`[${functionType}]`, 'special');
|
|
2520
|
+
}
|
|
2521
|
+
return options.stylize(`[${functionType} ${truncate(name, options.truncate - 11)}]`, 'special');
|
|
2522
|
+
}
|
|
2523
|
+
function inspectMapEntry([key, value], options) {
|
|
2524
|
+
options.truncate -= 4;
|
|
2525
|
+
key = options.inspect(key, options);
|
|
2526
|
+
options.truncate -= key.length;
|
|
2527
|
+
value = options.inspect(value, options);
|
|
2528
|
+
return `${key} => ${value}`;
|
|
2529
|
+
}
|
|
2530
|
+
// IE11 doesn't support `map.entries()`
|
|
2531
|
+
function mapToEntries(map) {
|
|
2532
|
+
const entries = [];
|
|
2533
|
+
map.forEach((value, key)=>{
|
|
2534
|
+
entries.push([
|
|
2535
|
+
key,
|
|
2536
|
+
value
|
|
2537
|
+
]);
|
|
2538
|
+
});
|
|
2539
|
+
return entries;
|
|
2540
|
+
}
|
|
2541
|
+
function inspectMap(map, options) {
|
|
2542
|
+
if (map.size === 0) return 'Map{}';
|
|
2543
|
+
options.truncate -= 7;
|
|
2544
|
+
return `Map{ ${inspectList(mapToEntries(map), options, inspectMapEntry)} }`;
|
|
2545
|
+
}
|
|
2546
|
+
const isNaN = Number.isNaN || ((i)=>i !== i); // eslint-disable-line no-self-compare
|
|
2547
|
+
function inspectNumber(number, options) {
|
|
2548
|
+
if (isNaN(number)) {
|
|
2549
|
+
return options.stylize('NaN', 'number');
|
|
2550
|
+
}
|
|
2551
|
+
if (number === Infinity) {
|
|
2552
|
+
return options.stylize('Infinity', 'number');
|
|
2553
|
+
}
|
|
2554
|
+
if (number === -Infinity) {
|
|
2555
|
+
return options.stylize('-Infinity', 'number');
|
|
2556
|
+
}
|
|
2557
|
+
if (number === 0) {
|
|
2558
|
+
return options.stylize(1 / number === Infinity ? '+0' : '-0', 'number');
|
|
2559
|
+
}
|
|
2560
|
+
return options.stylize(truncate(String(number), options.truncate), 'number');
|
|
2561
|
+
}
|
|
2562
|
+
function inspectBigInt(number, options) {
|
|
2563
|
+
let nums = truncate(number.toString(), options.truncate - 1);
|
|
2564
|
+
if (nums !== truncator) nums += 'n';
|
|
2565
|
+
return options.stylize(nums, 'bigint');
|
|
2566
|
+
}
|
|
2567
|
+
function inspectRegExp(value, options) {
|
|
2568
|
+
const flags = value.toString().split('/')[2];
|
|
2569
|
+
const sourceLength = options.truncate - (2 + flags.length);
|
|
2570
|
+
const source = value.source;
|
|
2571
|
+
return options.stylize(`/${truncate(source, sourceLength)}/${flags}`, 'regexp');
|
|
2572
|
+
}
|
|
2573
|
+
// IE11 doesn't support `Array.from(set)`
|
|
2574
|
+
function arrayFromSet(set) {
|
|
2575
|
+
const values = [];
|
|
2576
|
+
set.forEach((value)=>{
|
|
2577
|
+
values.push(value);
|
|
2578
|
+
});
|
|
2579
|
+
return values;
|
|
2580
|
+
}
|
|
2581
|
+
function inspectSet(set, options) {
|
|
2582
|
+
if (set.size === 0) return 'Set{}';
|
|
2583
|
+
options.truncate -= 7;
|
|
2584
|
+
return `Set{ ${inspectList(arrayFromSet(set), options)} }`;
|
|
2585
|
+
}
|
|
2586
|
+
const stringEscapeChars = new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5" + '\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]', 'g');
|
|
2587
|
+
const escapeCharacters = {
|
|
2588
|
+
'\b': '\\b',
|
|
2589
|
+
'\t': '\\t',
|
|
2590
|
+
'\n': '\\n',
|
|
2591
|
+
'\f': '\\f',
|
|
2592
|
+
'\r': '\\r',
|
|
2593
|
+
"'": "\\'",
|
|
2594
|
+
'\\': '\\\\'
|
|
2595
|
+
};
|
|
2596
|
+
const hex = 16;
|
|
2597
|
+
function escape(char) {
|
|
2598
|
+
return escapeCharacters[char] || `\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-4)}`;
|
|
2599
|
+
}
|
|
2600
|
+
function inspectString(string, options) {
|
|
2601
|
+
if (stringEscapeChars.test(string)) {
|
|
2602
|
+
string = string.replace(stringEscapeChars, escape);
|
|
2603
|
+
}
|
|
2604
|
+
return options.stylize(`'${truncate(string, options.truncate - 2)}'`, 'string');
|
|
2605
|
+
}
|
|
2606
|
+
function inspectSymbol(value) {
|
|
2607
|
+
if ('description' in Symbol.prototype) {
|
|
2608
|
+
return value.description ? `Symbol(${value.description})` : 'Symbol()';
|
|
2609
|
+
}
|
|
2610
|
+
return value.toString();
|
|
2611
|
+
}
|
|
2612
|
+
const getPromiseValue = ()=>'Promise{…}';
|
|
2613
|
+
function inspectObject$1(object, options) {
|
|
2614
|
+
const properties = Object.getOwnPropertyNames(object);
|
|
2615
|
+
const symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [];
|
|
2616
|
+
if (properties.length === 0 && symbols.length === 0) {
|
|
2617
|
+
return '{}';
|
|
2618
|
+
}
|
|
2619
|
+
options.truncate -= 4;
|
|
2620
|
+
options.seen = options.seen || [];
|
|
2621
|
+
if (options.seen.includes(object)) {
|
|
2622
|
+
return '[Circular]';
|
|
2623
|
+
}
|
|
2624
|
+
options.seen.push(object);
|
|
2625
|
+
const propertyContents = inspectList(properties.map((key)=>[
|
|
2626
|
+
key,
|
|
2627
|
+
object[key]
|
|
2628
|
+
]), options, inspectProperty);
|
|
2629
|
+
const symbolContents = inspectList(symbols.map((key)=>[
|
|
2630
|
+
key,
|
|
2631
|
+
object[key]
|
|
2632
|
+
]), options, inspectProperty);
|
|
2633
|
+
options.seen.pop();
|
|
2634
|
+
let sep = '';
|
|
2635
|
+
if (propertyContents && symbolContents) {
|
|
2636
|
+
sep = ', ';
|
|
2637
|
+
}
|
|
2638
|
+
return `{ ${propertyContents}${sep}${symbolContents} }`;
|
|
2639
|
+
}
|
|
2640
|
+
const toStringTag = typeof Symbol !== 'undefined' && Symbol.toStringTag ? Symbol.toStringTag : false;
|
|
2641
|
+
function inspectClass(value, options) {
|
|
2642
|
+
let name = '';
|
|
2643
|
+
if (toStringTag && toStringTag in value) {
|
|
2644
|
+
name = value[toStringTag];
|
|
2645
|
+
}
|
|
2646
|
+
name = name || value.constructor.name;
|
|
2647
|
+
// Babel transforms anonymous classes to the name `_class`
|
|
2648
|
+
if (!name || name === '_class') {
|
|
2649
|
+
name = '<Anonymous Class>';
|
|
2650
|
+
}
|
|
2651
|
+
options.truncate -= name.length;
|
|
2652
|
+
return `${name}${inspectObject$1(value, options)}`;
|
|
2653
|
+
}
|
|
2654
|
+
function inspectArguments(args, options) {
|
|
2655
|
+
if (args.length === 0) return 'Arguments[]';
|
|
2656
|
+
options.truncate -= 13;
|
|
2657
|
+
return `Arguments[ ${inspectList(args, options)} ]`;
|
|
2658
|
+
}
|
|
2659
|
+
const errorKeys = [
|
|
2660
|
+
'stack',
|
|
2661
|
+
'line',
|
|
2662
|
+
'column',
|
|
2663
|
+
'name',
|
|
2664
|
+
'message',
|
|
2665
|
+
'fileName',
|
|
2666
|
+
'lineNumber',
|
|
2667
|
+
'columnNumber',
|
|
2668
|
+
'number',
|
|
2669
|
+
'description',
|
|
2670
|
+
'cause'
|
|
2671
|
+
];
|
|
2672
|
+
function inspectObject(error, options) {
|
|
2673
|
+
const properties = Object.getOwnPropertyNames(error).filter((key)=>errorKeys.indexOf(key) === -1);
|
|
2674
|
+
const name = error.name;
|
|
2675
|
+
options.truncate -= name.length;
|
|
2676
|
+
let message = '';
|
|
2677
|
+
if (typeof error.message === 'string') {
|
|
2678
|
+
message = truncate(error.message, options.truncate);
|
|
2679
|
+
} else {
|
|
2680
|
+
properties.unshift('message');
|
|
2681
|
+
}
|
|
2682
|
+
message = message ? `: ${message}` : '';
|
|
2683
|
+
options.truncate -= message.length + 5;
|
|
2684
|
+
options.seen = options.seen || [];
|
|
2685
|
+
if (options.seen.includes(error)) {
|
|
2686
|
+
return '[Circular]';
|
|
2687
|
+
}
|
|
2688
|
+
options.seen.push(error);
|
|
2689
|
+
const propertyContents = inspectList(properties.map((key)=>[
|
|
2690
|
+
key,
|
|
2691
|
+
error[key]
|
|
2692
|
+
]), options, inspectProperty);
|
|
2693
|
+
return `${name}${message}${propertyContents ? ` { ${propertyContents} }` : ''}`;
|
|
2694
|
+
}
|
|
2695
|
+
function inspectAttribute([key, value], options) {
|
|
2696
|
+
options.truncate -= 3;
|
|
2697
|
+
if (!value) {
|
|
2698
|
+
return `${options.stylize(String(key), 'yellow')}`;
|
|
2699
|
+
}
|
|
2700
|
+
return `${options.stylize(String(key), 'yellow')}=${options.stylize(`"${value}"`, 'string')}`;
|
|
2701
|
+
}
|
|
2702
|
+
function inspectNodeCollection(collection, options) {
|
|
2703
|
+
return inspectList(collection, options, inspectNode, '\n');
|
|
2704
|
+
}
|
|
2705
|
+
function inspectNode(node, options) {
|
|
2706
|
+
switch(node.nodeType){
|
|
2707
|
+
case 1:
|
|
2708
|
+
return inspectHTML(node, options);
|
|
2709
|
+
case 3:
|
|
2710
|
+
return options.inspect(node.data, options);
|
|
2711
|
+
default:
|
|
2712
|
+
return options.inspect(node, options);
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
// @ts-ignore (Deno doesn't have Element)
|
|
2716
|
+
function inspectHTML(element, options) {
|
|
2717
|
+
const properties = element.getAttributeNames();
|
|
2718
|
+
const name = element.tagName.toLowerCase();
|
|
2719
|
+
const head = options.stylize(`<${name}`, 'special');
|
|
2720
|
+
const headClose = options.stylize(`>`, 'special');
|
|
2721
|
+
const tail = options.stylize(`</${name}>`, 'special');
|
|
2722
|
+
options.truncate -= name.length * 2 + 5;
|
|
2723
|
+
let propertyContents = '';
|
|
2724
|
+
if (properties.length > 0) {
|
|
2725
|
+
propertyContents += ' ';
|
|
2726
|
+
propertyContents += inspectList(properties.map((key)=>[
|
|
2727
|
+
key,
|
|
2728
|
+
element.getAttribute(key)
|
|
2729
|
+
]), options, inspectAttribute, ' ');
|
|
2730
|
+
}
|
|
2731
|
+
options.truncate -= propertyContents.length;
|
|
2732
|
+
const truncate = options.truncate;
|
|
2733
|
+
let children = inspectNodeCollection(element.children, options);
|
|
2734
|
+
if (children && children.length > truncate) {
|
|
2735
|
+
children = `${truncator}(${element.children.length})`;
|
|
2736
|
+
}
|
|
2737
|
+
return `${head}${propertyContents}${headClose}${children}${tail}`;
|
|
2738
|
+
}
|
|
2739
|
+
/* !
|
|
2740
|
+
* loupe
|
|
2741
|
+
* Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
|
|
2742
|
+
* MIT Licensed
|
|
2743
|
+
*/ const symbolsSupported = typeof Symbol === 'function' && typeof Symbol.for === 'function';
|
|
2744
|
+
const chaiInspect = symbolsSupported ? Symbol.for('chai/inspect') : '@@chai/inspect';
|
|
2745
|
+
const nodeInspect = Symbol.for('nodejs.util.inspect.custom');
|
|
2746
|
+
const constructorMap = new WeakMap();
|
|
2747
|
+
const stringTagMap = {};
|
|
2748
|
+
const baseTypesMap = {
|
|
2749
|
+
undefined: (value, options)=>options.stylize('undefined', 'undefined'),
|
|
2750
|
+
null: (value, options)=>options.stylize('null', 'null'),
|
|
2751
|
+
boolean: (value, options)=>options.stylize(String(value), 'boolean'),
|
|
2752
|
+
Boolean: (value, options)=>options.stylize(String(value), 'boolean'),
|
|
2753
|
+
number: inspectNumber,
|
|
2754
|
+
Number: inspectNumber,
|
|
2755
|
+
bigint: inspectBigInt,
|
|
2756
|
+
BigInt: inspectBigInt,
|
|
2757
|
+
string: inspectString,
|
|
2758
|
+
String: inspectString,
|
|
2759
|
+
function: inspectFunction,
|
|
2760
|
+
Function: inspectFunction,
|
|
2761
|
+
symbol: inspectSymbol,
|
|
2762
|
+
// A Symbol polyfill will return `Symbol` not `symbol` from typedetect
|
|
2763
|
+
Symbol: inspectSymbol,
|
|
2764
|
+
Array: inspectArray,
|
|
2765
|
+
Date: inspectDate,
|
|
2766
|
+
Map: inspectMap,
|
|
2767
|
+
Set: inspectSet,
|
|
2768
|
+
RegExp: inspectRegExp,
|
|
2769
|
+
Promise: getPromiseValue,
|
|
2770
|
+
// WeakSet, WeakMap are totally opaque to us
|
|
2771
|
+
WeakSet: (value, options)=>options.stylize('WeakSet{…}', 'special'),
|
|
2772
|
+
WeakMap: (value, options)=>options.stylize('WeakMap{…}', 'special'),
|
|
2773
|
+
Arguments: inspectArguments,
|
|
2774
|
+
Int8Array: inspectTypedArray,
|
|
2775
|
+
Uint8Array: inspectTypedArray,
|
|
2776
|
+
Uint8ClampedArray: inspectTypedArray,
|
|
2777
|
+
Int16Array: inspectTypedArray,
|
|
2778
|
+
Uint16Array: inspectTypedArray,
|
|
2779
|
+
Int32Array: inspectTypedArray,
|
|
2780
|
+
Uint32Array: inspectTypedArray,
|
|
2781
|
+
Float32Array: inspectTypedArray,
|
|
2782
|
+
Float64Array: inspectTypedArray,
|
|
2783
|
+
Generator: ()=>'',
|
|
2784
|
+
DataView: ()=>'',
|
|
2785
|
+
ArrayBuffer: ()=>'',
|
|
2786
|
+
Error: inspectObject,
|
|
2787
|
+
HTMLCollection: inspectNodeCollection,
|
|
2788
|
+
NodeList: inspectNodeCollection
|
|
2789
|
+
};
|
|
2790
|
+
// eslint-disable-next-line complexity
|
|
2791
|
+
const inspectCustom = (value, options, type, inspectFn)=>{
|
|
2792
|
+
if (chaiInspect in value && typeof value[chaiInspect] === 'function') {
|
|
2793
|
+
return value[chaiInspect](options);
|
|
2794
|
+
}
|
|
2795
|
+
if (nodeInspect in value && typeof value[nodeInspect] === 'function') {
|
|
2796
|
+
return value[nodeInspect](options.depth, options, inspectFn);
|
|
2797
|
+
}
|
|
2798
|
+
if ('inspect' in value && typeof value.inspect === 'function') {
|
|
2799
|
+
return value.inspect(options.depth, options);
|
|
2800
|
+
}
|
|
2801
|
+
if ('constructor' in value && constructorMap.has(value.constructor)) {
|
|
2802
|
+
return constructorMap.get(value.constructor)(value, options);
|
|
2803
|
+
}
|
|
2804
|
+
if (stringTagMap[type]) {
|
|
2805
|
+
return stringTagMap[type](value, options);
|
|
2806
|
+
}
|
|
2807
|
+
return '';
|
|
2808
|
+
};
|
|
2809
|
+
const toString = Object.prototype.toString;
|
|
2810
|
+
// eslint-disable-next-line complexity
|
|
2811
|
+
function inspect$1(value, opts = {}) {
|
|
2812
|
+
const options = normaliseOptions(opts, inspect$1);
|
|
2813
|
+
const { customInspect } = options;
|
|
2814
|
+
let type = value === null ? 'null' : typeof value;
|
|
2815
|
+
if (type === 'object') {
|
|
2816
|
+
type = toString.call(value).slice(8, -1);
|
|
2817
|
+
}
|
|
2818
|
+
// If it is a base value that we already support, then use Loupe's inspector
|
|
2819
|
+
if (type in baseTypesMap) {
|
|
2820
|
+
return baseTypesMap[type](value, options);
|
|
2821
|
+
}
|
|
2822
|
+
// If `options.customInspect` is set to true then try to use the custom inspector
|
|
2823
|
+
if (customInspect && value) {
|
|
2824
|
+
const output = inspectCustom(value, options, type, inspect$1);
|
|
2825
|
+
if (output) {
|
|
2826
|
+
if (typeof output === 'string') return output;
|
|
2827
|
+
return inspect$1(output, options);
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
const proto = value ? Object.getPrototypeOf(value) : false;
|
|
2831
|
+
// If it's a plain Object then use Loupe's inspector
|
|
2832
|
+
if (proto === Object.prototype || proto === null) {
|
|
2833
|
+
return inspectObject$1(value, options);
|
|
2834
|
+
}
|
|
2835
|
+
// Specifically account for HTMLElements
|
|
2836
|
+
// @ts-ignore
|
|
2837
|
+
if (value && typeof HTMLElement === 'function' && value instanceof HTMLElement) {
|
|
2838
|
+
return inspectHTML(value, options);
|
|
2839
|
+
}
|
|
2840
|
+
if ('constructor' in value) {
|
|
2841
|
+
// If it is a class, inspect it like an object but add the constructor name
|
|
2842
|
+
if (value.constructor !== Object) {
|
|
2843
|
+
return inspectClass(value, options);
|
|
2844
|
+
}
|
|
2845
|
+
// If it is an object with an anonymous prototype, display it as an object.
|
|
2846
|
+
return inspectObject$1(value, options);
|
|
2847
|
+
}
|
|
2848
|
+
// last chance to check if it's an object
|
|
2849
|
+
if (value === Object(value)) {
|
|
2850
|
+
return inspectObject$1(value, options);
|
|
2851
|
+
}
|
|
2852
|
+
// We have run out of options! Just stringify the value
|
|
2853
|
+
return options.stylize(String(value), type);
|
|
2854
|
+
}
|
|
2855
|
+
const { AsymmetricMatcher, DOMCollection, DOMElement, Immutable, ReactElement, ReactTestComponent } = plugins;
|
|
2856
|
+
const PLUGINS = [
|
|
2857
|
+
ReactTestComponent,
|
|
2858
|
+
ReactElement,
|
|
2859
|
+
DOMElement,
|
|
2860
|
+
DOMCollection,
|
|
2861
|
+
Immutable,
|
|
2862
|
+
AsymmetricMatcher
|
|
2863
|
+
];
|
|
2864
|
+
function stringify(object, maxDepth = 10, { maxLength, ...options } = {}) {
|
|
2865
|
+
const MAX_LENGTH = maxLength ?? 1e4;
|
|
2866
|
+
let result;
|
|
2867
|
+
try {
|
|
2868
|
+
result = format$1(object, {
|
|
2869
|
+
maxDepth,
|
|
2870
|
+
escapeString: false,
|
|
2871
|
+
plugins: PLUGINS,
|
|
2872
|
+
...options
|
|
2873
|
+
});
|
|
2874
|
+
} catch {
|
|
2875
|
+
result = format$1(object, {
|
|
2876
|
+
callToJSON: false,
|
|
2877
|
+
maxDepth,
|
|
2878
|
+
escapeString: false,
|
|
2879
|
+
plugins: PLUGINS,
|
|
2880
|
+
...options
|
|
2881
|
+
});
|
|
2882
|
+
}
|
|
2883
|
+
// Prevents infinite loop https://github.com/vitest-dev/vitest/issues/7249
|
|
2884
|
+
return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(Math.min(maxDepth, Number.MAX_SAFE_INTEGER) / 2), {
|
|
2885
|
+
maxLength,
|
|
2886
|
+
...options
|
|
2887
|
+
}) : result;
|
|
2888
|
+
}
|
|
2889
|
+
const formatRegExp = /%[sdjifoOc%]/g;
|
|
2890
|
+
function baseFormat(args, options = {}) {
|
|
2891
|
+
const formatArg = (item, inspecOptions)=>{
|
|
2892
|
+
if (options.prettifyObject) {
|
|
2893
|
+
return stringify(item, undefined, {
|
|
2894
|
+
printBasicPrototype: false,
|
|
2895
|
+
escapeString: false
|
|
2896
|
+
});
|
|
2897
|
+
}
|
|
2898
|
+
return inspect(item, inspecOptions);
|
|
2899
|
+
};
|
|
2900
|
+
if (typeof args[0] !== "string") {
|
|
2901
|
+
const objects = [];
|
|
2902
|
+
for(let i = 0; i < args.length; i++){
|
|
2903
|
+
objects.push(formatArg(args[i], {
|
|
2904
|
+
depth: 0,
|
|
2905
|
+
colors: false
|
|
2906
|
+
}));
|
|
2907
|
+
}
|
|
2908
|
+
return objects.join(" ");
|
|
2909
|
+
}
|
|
2910
|
+
const len = args.length;
|
|
2911
|
+
let i = 1;
|
|
2912
|
+
const template = args[0];
|
|
2913
|
+
let str = String(template).replace(formatRegExp, (x)=>{
|
|
2914
|
+
if (x === "%%") {
|
|
2915
|
+
return "%";
|
|
2916
|
+
}
|
|
2917
|
+
if (i >= len) {
|
|
2918
|
+
return x;
|
|
2919
|
+
}
|
|
2920
|
+
switch(x){
|
|
2921
|
+
case "%s":
|
|
2922
|
+
{
|
|
2923
|
+
const value = args[i++];
|
|
2924
|
+
if (typeof value === "bigint") {
|
|
2925
|
+
return `${value.toString()}n`;
|
|
2926
|
+
}
|
|
2927
|
+
if (typeof value === "number" && value === 0 && 1 / value < 0) {
|
|
2928
|
+
return "-0";
|
|
2929
|
+
}
|
|
2930
|
+
if (typeof value === "object" && value !== null) {
|
|
2931
|
+
if (typeof value.toString === "function" && value.toString !== Object.prototype.toString) {
|
|
2932
|
+
return value.toString();
|
|
2933
|
+
}
|
|
2934
|
+
return formatArg(value, {
|
|
2935
|
+
depth: 0,
|
|
2936
|
+
colors: false
|
|
2937
|
+
});
|
|
2938
|
+
}
|
|
2939
|
+
return String(value);
|
|
2940
|
+
}
|
|
2941
|
+
case "%d":
|
|
2942
|
+
{
|
|
2943
|
+
const value = args[i++];
|
|
2944
|
+
if (typeof value === "bigint") {
|
|
2945
|
+
return `${value.toString()}n`;
|
|
2946
|
+
}
|
|
2947
|
+
return Number(value).toString();
|
|
2948
|
+
}
|
|
2949
|
+
case "%i":
|
|
2950
|
+
{
|
|
2951
|
+
const value = args[i++];
|
|
2952
|
+
if (typeof value === "bigint") {
|
|
2953
|
+
return `${value.toString()}n`;
|
|
2954
|
+
}
|
|
2955
|
+
return Number.parseInt(String(value)).toString();
|
|
2956
|
+
}
|
|
2957
|
+
case "%f":
|
|
2958
|
+
return Number.parseFloat(String(args[i++])).toString();
|
|
2959
|
+
case "%o":
|
|
2960
|
+
return formatArg(args[i++], {
|
|
2961
|
+
showHidden: true,
|
|
2962
|
+
showProxy: true
|
|
2963
|
+
});
|
|
2964
|
+
case "%O":
|
|
2965
|
+
return formatArg(args[i++]);
|
|
2966
|
+
case "%c":
|
|
2967
|
+
{
|
|
2968
|
+
i++;
|
|
2969
|
+
return "";
|
|
2970
|
+
}
|
|
2971
|
+
case "%j":
|
|
2972
|
+
try {
|
|
2973
|
+
return JSON.stringify(args[i++]);
|
|
2974
|
+
} catch (err) {
|
|
2975
|
+
const m = err.message;
|
|
2976
|
+
if (m.includes("circular structure") || m.includes("cyclic structures") || m.includes("cyclic object")) {
|
|
2977
|
+
return "[Circular]";
|
|
2978
|
+
}
|
|
2979
|
+
throw err;
|
|
2980
|
+
}
|
|
2981
|
+
default:
|
|
2982
|
+
return x;
|
|
2983
|
+
}
|
|
2984
|
+
});
|
|
2985
|
+
for(let x = args[i]; i < len; x = args[++i]){
|
|
2986
|
+
if (x === null || typeof x !== "object") {
|
|
2987
|
+
str += ` ${x}`;
|
|
2988
|
+
} else {
|
|
2989
|
+
str += ` ${formatArg(x)}`;
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2992
|
+
return str;
|
|
2993
|
+
}
|
|
2994
|
+
function format(...args) {
|
|
2995
|
+
return baseFormat(args);
|
|
2996
|
+
}
|
|
2997
|
+
function inspect(obj, options = {}) {
|
|
2998
|
+
if (options.truncate === 0) {
|
|
2999
|
+
options.truncate = Number.POSITIVE_INFINITY;
|
|
3000
|
+
}
|
|
3001
|
+
return inspect$1(obj, options);
|
|
3002
|
+
}
|
|
3003
|
+
function objDisplay(obj, options = {}) {
|
|
3004
|
+
if (typeof options.truncate === "undefined") {
|
|
3005
|
+
options.truncate = 40;
|
|
3006
|
+
}
|
|
3007
|
+
const str = inspect(obj, options);
|
|
3008
|
+
const type = Object.prototype.toString.call(obj);
|
|
3009
|
+
if (options.truncate && str.length >= options.truncate) {
|
|
3010
|
+
if (type === "[object Function]") {
|
|
3011
|
+
const fn = obj;
|
|
3012
|
+
return !fn.name ? "[Function]" : `[Function: ${fn.name}]`;
|
|
3013
|
+
} else if (type === "[object Array]") {
|
|
3014
|
+
return `[ Array(${obj.length}) ]`;
|
|
3015
|
+
} else if (type === "[object Object]") {
|
|
3016
|
+
const keys = Object.keys(obj);
|
|
3017
|
+
const kstr = keys.length > 2 ? `${keys.splice(0, 2).join(", ")}, ...` : keys.join(", ");
|
|
3018
|
+
return `{ Object (${kstr}) }`;
|
|
3019
|
+
} else {
|
|
3020
|
+
return str;
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
return str;
|
|
3024
|
+
}
|
|
3025
|
+
|
|
3026
|
+
function assertTypes(value, name, types) {
|
|
3027
|
+
const receivedType = typeof value;
|
|
3028
|
+
const pass = types.includes(receivedType);
|
|
3029
|
+
if (!pass) {
|
|
3030
|
+
throw new TypeError(`${name} value must be ${types.join(" or ")}, received "${receivedType}"`);
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
function toArray(array) {
|
|
3034
|
+
if (array === null || array === undefined) {
|
|
3035
|
+
array = [];
|
|
3036
|
+
}
|
|
3037
|
+
if (Array.isArray(array)) {
|
|
3038
|
+
return array;
|
|
3039
|
+
}
|
|
3040
|
+
return [
|
|
3041
|
+
array
|
|
3042
|
+
];
|
|
3043
|
+
}
|
|
3044
|
+
function isObject(item) {
|
|
3045
|
+
return item != null && typeof item === "object" && !Array.isArray(item);
|
|
3046
|
+
}
|
|
3047
|
+
function objectAttr(source, path, defaultValue = undefined) {
|
|
3048
|
+
// a[3].b -> a.3.b
|
|
3049
|
+
const paths = path.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
3050
|
+
let result = source;
|
|
3051
|
+
for (const p of paths){
|
|
3052
|
+
result = new Object(result)[p];
|
|
3053
|
+
if (result === undefined) {
|
|
3054
|
+
return defaultValue;
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
return result;
|
|
3058
|
+
}
|
|
3059
|
+
function createDefer() {
|
|
3060
|
+
let resolve = null;
|
|
3061
|
+
let reject = null;
|
|
3062
|
+
const p = new Promise((_resolve, _reject)=>{
|
|
3063
|
+
resolve = _resolve;
|
|
3064
|
+
reject = _reject;
|
|
3065
|
+
});
|
|
3066
|
+
p.resolve = resolve;
|
|
3067
|
+
p.reject = reject;
|
|
3068
|
+
return p;
|
|
3069
|
+
}
|
|
3070
|
+
function isNegativeNaN(val) {
|
|
3071
|
+
if (!Number.isNaN(val)) {
|
|
3072
|
+
return false;
|
|
3073
|
+
}
|
|
3074
|
+
const f64 = new Float64Array(1);
|
|
3075
|
+
f64[0] = val;
|
|
3076
|
+
const u32 = new Uint32Array(f64.buffer);
|
|
3077
|
+
const isNegative = u32[1] >>> 31 === 1;
|
|
3078
|
+
return isNegative;
|
|
3079
|
+
}
|
|
3080
|
+
|
|
3081
|
+
const SAFE_TIMERS_SYMBOL = Symbol("vitest:SAFE_TIMERS");
|
|
3082
|
+
function getSafeTimers() {
|
|
3083
|
+
const { setTimeout: safeSetTimeout, setInterval: safeSetInterval, clearInterval: safeClearInterval, clearTimeout: safeClearTimeout, setImmediate: safeSetImmediate, clearImmediate: safeClearImmediate, queueMicrotask: safeQueueMicrotask } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis;
|
|
3084
|
+
const { nextTick: safeNextTick } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis.process || {};
|
|
3085
|
+
return {
|
|
3086
|
+
nextTick: safeNextTick,
|
|
3087
|
+
setTimeout: safeSetTimeout,
|
|
3088
|
+
setInterval: safeSetInterval,
|
|
3089
|
+
clearInterval: safeClearInterval,
|
|
3090
|
+
clearTimeout: safeClearTimeout,
|
|
3091
|
+
setImmediate: safeSetImmediate,
|
|
3092
|
+
clearImmediate: safeClearImmediate,
|
|
3093
|
+
queueMicrotask: safeQueueMicrotask
|
|
3094
|
+
};
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3097
|
+
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
3098
|
+
function normalizeWindowsPath(input = "") {
|
|
3099
|
+
if (!input) {
|
|
3100
|
+
return input;
|
|
3101
|
+
}
|
|
3102
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r)=>r.toUpperCase());
|
|
3103
|
+
}
|
|
3104
|
+
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
3105
|
+
function cwd() {
|
|
3106
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
3107
|
+
return process.cwd().replace(/\\/g, "/");
|
|
3108
|
+
}
|
|
3109
|
+
return "/";
|
|
3110
|
+
}
|
|
3111
|
+
const resolve = function(...arguments_) {
|
|
3112
|
+
arguments_ = arguments_.map((argument)=>normalizeWindowsPath(argument));
|
|
3113
|
+
let resolvedPath = "";
|
|
3114
|
+
let resolvedAbsolute = false;
|
|
3115
|
+
for(let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--){
|
|
3116
|
+
const path = index >= 0 ? arguments_[index] : cwd();
|
|
3117
|
+
if (!path || path.length === 0) {
|
|
3118
|
+
continue;
|
|
3119
|
+
}
|
|
3120
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
3121
|
+
resolvedAbsolute = isAbsolute(path);
|
|
3122
|
+
}
|
|
3123
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
3124
|
+
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
3125
|
+
return `/${resolvedPath}`;
|
|
3126
|
+
}
|
|
3127
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
3128
|
+
};
|
|
3129
|
+
function normalizeString(path, allowAboveRoot) {
|
|
3130
|
+
let res = "";
|
|
3131
|
+
let lastSegmentLength = 0;
|
|
3132
|
+
let lastSlash = -1;
|
|
3133
|
+
let dots = 0;
|
|
3134
|
+
let char = null;
|
|
3135
|
+
for(let index = 0; index <= path.length; ++index){
|
|
3136
|
+
if (index < path.length) {
|
|
3137
|
+
char = path[index];
|
|
3138
|
+
} else if (char === "/") {
|
|
3139
|
+
break;
|
|
3140
|
+
} else {
|
|
3141
|
+
char = "/";
|
|
3142
|
+
}
|
|
3143
|
+
if (char === "/") {
|
|
3144
|
+
if (lastSlash === index - 1 || dots === 1) ;
|
|
3145
|
+
else if (dots === 2) {
|
|
3146
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
3147
|
+
if (res.length > 2) {
|
|
3148
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
3149
|
+
if (lastSlashIndex === -1) {
|
|
3150
|
+
res = "";
|
|
3151
|
+
lastSegmentLength = 0;
|
|
3152
|
+
} else {
|
|
3153
|
+
res = res.slice(0, lastSlashIndex);
|
|
3154
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
3155
|
+
}
|
|
3156
|
+
lastSlash = index;
|
|
3157
|
+
dots = 0;
|
|
3158
|
+
continue;
|
|
3159
|
+
} else if (res.length > 0) {
|
|
3160
|
+
res = "";
|
|
3161
|
+
lastSegmentLength = 0;
|
|
3162
|
+
lastSlash = index;
|
|
3163
|
+
dots = 0;
|
|
3164
|
+
continue;
|
|
3165
|
+
}
|
|
3166
|
+
}
|
|
3167
|
+
if (allowAboveRoot) {
|
|
3168
|
+
res += res.length > 0 ? "/.." : "..";
|
|
3169
|
+
lastSegmentLength = 2;
|
|
3170
|
+
}
|
|
3171
|
+
} else {
|
|
3172
|
+
if (res.length > 0) {
|
|
3173
|
+
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
3174
|
+
} else {
|
|
3175
|
+
res = path.slice(lastSlash + 1, index);
|
|
3176
|
+
}
|
|
3177
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
3178
|
+
}
|
|
3179
|
+
lastSlash = index;
|
|
3180
|
+
dots = 0;
|
|
3181
|
+
} else if (char === "." && dots !== -1) {
|
|
3182
|
+
++dots;
|
|
3183
|
+
} else {
|
|
3184
|
+
dots = -1;
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
return res;
|
|
3188
|
+
}
|
|
3189
|
+
const isAbsolute = function(p) {
|
|
3190
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
3191
|
+
};
|
|
3192
|
+
|
|
3193
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
3194
|
+
var intToChar = new Uint8Array(64);
|
|
3195
|
+
var charToInt = new Uint8Array(128);
|
|
3196
|
+
for(let i = 0; i < chars.length; i++){
|
|
3197
|
+
const c = chars.charCodeAt(i);
|
|
3198
|
+
intToChar[i] = c;
|
|
3199
|
+
charToInt[c] = i;
|
|
3200
|
+
}
|
|
3201
|
+
const CHROME_IE_STACK_REGEXP = /^\s*at .*(?:\S:\d+|\(native\))/m;
|
|
3202
|
+
const SAFARI_NATIVE_CODE_REGEXP = /^(?:eval@)?(?:\[native code\])?$/;
|
|
3203
|
+
function extractLocation(urlLike) {
|
|
3204
|
+
// Fail-fast but return locations like "(native)"
|
|
3205
|
+
if (!urlLike.includes(":")) {
|
|
3206
|
+
return [
|
|
3207
|
+
urlLike
|
|
3208
|
+
];
|
|
3209
|
+
}
|
|
3210
|
+
const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
|
|
3211
|
+
const parts = regExp.exec(urlLike.replace(/^\(|\)$/g, ""));
|
|
3212
|
+
if (!parts) {
|
|
3213
|
+
return [
|
|
3214
|
+
urlLike
|
|
3215
|
+
];
|
|
3216
|
+
}
|
|
3217
|
+
let url = parts[1];
|
|
3218
|
+
if (url.startsWith("async ")) {
|
|
3219
|
+
url = url.slice(6);
|
|
3220
|
+
}
|
|
3221
|
+
if (url.startsWith("http:") || url.startsWith("https:")) {
|
|
3222
|
+
const urlObj = new URL(url);
|
|
3223
|
+
urlObj.searchParams.delete("import");
|
|
3224
|
+
urlObj.searchParams.delete("browserv");
|
|
3225
|
+
url = urlObj.pathname + urlObj.hash + urlObj.search;
|
|
3226
|
+
}
|
|
3227
|
+
if (url.startsWith("/@fs/")) {
|
|
3228
|
+
const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
|
|
3229
|
+
url = url.slice(isWindows ? 5 : 4);
|
|
3230
|
+
}
|
|
3231
|
+
return [
|
|
3232
|
+
url,
|
|
3233
|
+
parts[2] || undefined,
|
|
3234
|
+
parts[3] || undefined
|
|
3235
|
+
];
|
|
3236
|
+
}
|
|
3237
|
+
function parseSingleFFOrSafariStack(raw) {
|
|
3238
|
+
let line = raw.trim();
|
|
3239
|
+
if (SAFARI_NATIVE_CODE_REGEXP.test(line)) {
|
|
3240
|
+
return null;
|
|
3241
|
+
}
|
|
3242
|
+
if (line.includes(" > eval")) {
|
|
3243
|
+
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
|
|
3244
|
+
}
|
|
3245
|
+
// Early return for lines that don't look like Firefox/Safari stack traces
|
|
3246
|
+
// Firefox/Safari stack traces must contain '@' and should have location info after it
|
|
3247
|
+
if (!line.includes("@")) {
|
|
3248
|
+
return null;
|
|
3249
|
+
}
|
|
3250
|
+
// Find the correct @ that separates function name from location
|
|
3251
|
+
// For cases like '@https://@fs/path' or 'functionName@https://@fs/path'
|
|
3252
|
+
// we need to find the first @ that precedes a valid location (containing :)
|
|
3253
|
+
let atIndex = -1;
|
|
3254
|
+
let locationPart = "";
|
|
3255
|
+
let functionName;
|
|
3256
|
+
// Try each @ from left to right to find the one that gives us a valid location
|
|
3257
|
+
for(let i = 0; i < line.length; i++){
|
|
3258
|
+
if (line[i] === "@") {
|
|
3259
|
+
const candidateLocation = line.slice(i + 1);
|
|
3260
|
+
// Minimum length 3 for valid location: 1 for filename + 1 for colon + 1 for line number (e.g., "a:1")
|
|
3261
|
+
if (candidateLocation.includes(":") && candidateLocation.length >= 3) {
|
|
3262
|
+
atIndex = i;
|
|
3263
|
+
locationPart = candidateLocation;
|
|
3264
|
+
functionName = i > 0 ? line.slice(0, i) : undefined;
|
|
3265
|
+
break;
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
// Validate we found a valid location with minimum length (filename:line format)
|
|
3270
|
+
if (atIndex === -1 || !locationPart.includes(":") || locationPart.length < 3) {
|
|
3271
|
+
return null;
|
|
3272
|
+
}
|
|
3273
|
+
const [url, lineNumber, columnNumber] = extractLocation(locationPart);
|
|
3274
|
+
if (!url || !lineNumber || !columnNumber) {
|
|
3275
|
+
return null;
|
|
3276
|
+
}
|
|
3277
|
+
return {
|
|
3278
|
+
file: url,
|
|
3279
|
+
method: functionName || "",
|
|
3280
|
+
line: Number.parseInt(lineNumber),
|
|
3281
|
+
column: Number.parseInt(columnNumber)
|
|
3282
|
+
};
|
|
3283
|
+
}
|
|
3284
|
+
function parseSingleStack(raw) {
|
|
3285
|
+
const line = raw.trim();
|
|
3286
|
+
if (!CHROME_IE_STACK_REGEXP.test(line)) {
|
|
3287
|
+
return parseSingleFFOrSafariStack(line);
|
|
3288
|
+
}
|
|
3289
|
+
return parseSingleV8Stack(line);
|
|
3290
|
+
}
|
|
3291
|
+
// Based on https://github.com/stacktracejs/error-stack-parser
|
|
3292
|
+
// Credit to stacktracejs
|
|
3293
|
+
function parseSingleV8Stack(raw) {
|
|
3294
|
+
let line = raw.trim();
|
|
3295
|
+
if (!CHROME_IE_STACK_REGEXP.test(line)) {
|
|
3296
|
+
return null;
|
|
3297
|
+
}
|
|
3298
|
+
if (line.includes("(eval ")) {
|
|
3299
|
+
line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
|
|
3300
|
+
}
|
|
3301
|
+
let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
|
|
3302
|
+
// capture and preserve the parenthesized location "(/foo/my bar.js:12:87)" in
|
|
3303
|
+
// case it has spaces in it, as the string is split on \s+ later on
|
|
3304
|
+
const location = sanitizedLine.match(/ (\(.+\)$)/);
|
|
3305
|
+
// remove the parenthesized location from the line, if it was matched
|
|
3306
|
+
sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
|
|
3307
|
+
// if a location was matched, pass it to extractLocation() otherwise pass all sanitizedLine
|
|
3308
|
+
// because this line doesn't have function name
|
|
3309
|
+
const [url, lineNumber, columnNumber] = extractLocation(location ? location[1] : sanitizedLine);
|
|
3310
|
+
let method = location && sanitizedLine || "";
|
|
3311
|
+
let file = url && [
|
|
3312
|
+
"eval",
|
|
3313
|
+
"<anonymous>"
|
|
3314
|
+
].includes(url) ? undefined : url;
|
|
3315
|
+
if (!file || !lineNumber || !columnNumber) {
|
|
3316
|
+
return null;
|
|
3317
|
+
}
|
|
3318
|
+
if (method.startsWith("async ")) {
|
|
3319
|
+
method = method.slice(6);
|
|
3320
|
+
}
|
|
3321
|
+
if (file.startsWith("file://")) {
|
|
3322
|
+
file = file.slice(7);
|
|
3323
|
+
}
|
|
3324
|
+
// normalize Windows path (\ -> /)
|
|
3325
|
+
file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve(file);
|
|
3326
|
+
if (method) {
|
|
3327
|
+
method = method.replace(/__vite_ssr_import_\d+__\./g, "").replace(/(Object\.)?__vite_ssr_export_default__\s?/g, "");
|
|
3328
|
+
}
|
|
3329
|
+
return {
|
|
3330
|
+
method,
|
|
3331
|
+
file,
|
|
3332
|
+
line: Number.parseInt(lineNumber),
|
|
3333
|
+
column: Number.parseInt(columnNumber)
|
|
3334
|
+
};
|
|
3335
|
+
}
|
|
3336
|
+
|
|
3337
|
+
function createChainable(keys, fn) {
|
|
3338
|
+
function create(context) {
|
|
3339
|
+
const chain = function(...args) {
|
|
3340
|
+
return fn.apply(context, args);
|
|
3341
|
+
};
|
|
3342
|
+
Object.assign(chain, fn);
|
|
3343
|
+
chain.withContext = ()=>chain.bind(context);
|
|
3344
|
+
chain.setContext = (key, value)=>{
|
|
3345
|
+
context[key] = value;
|
|
3346
|
+
};
|
|
3347
|
+
chain.mergeContext = (ctx)=>{
|
|
3348
|
+
Object.assign(context, ctx);
|
|
3349
|
+
};
|
|
3350
|
+
for (const key of keys){
|
|
3351
|
+
Object.defineProperty(chain, key, {
|
|
3352
|
+
get () {
|
|
3353
|
+
return create({
|
|
3354
|
+
...context,
|
|
3355
|
+
[key]: true
|
|
3356
|
+
});
|
|
3357
|
+
}
|
|
3358
|
+
});
|
|
3359
|
+
}
|
|
3360
|
+
return chain;
|
|
3361
|
+
}
|
|
3362
|
+
const chain = create({});
|
|
3363
|
+
chain.fn = fn;
|
|
3364
|
+
return chain;
|
|
3365
|
+
}
|
|
3366
|
+
function findTestFileStackTrace(testFilePath, error) {
|
|
3367
|
+
// first line is the error message
|
|
3368
|
+
const lines = error.split("\n").slice(1);
|
|
3369
|
+
for (const line of lines){
|
|
3370
|
+
const stack = parseSingleStack(line);
|
|
3371
|
+
if (stack && stack.file === testFilePath) {
|
|
3372
|
+
return stack;
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3376
|
+
function createTaskName(names, separator = " > ") {
|
|
3377
|
+
return names.filter((name)=>name !== undefined).join(separator);
|
|
3378
|
+
}
|
|
3379
|
+
|
|
3380
|
+
class PendingError extends Error {
|
|
3381
|
+
constructor(message, task, note){
|
|
3382
|
+
super(message), this.code = "VITEST_PENDING";
|
|
3383
|
+
this.message = message;
|
|
3384
|
+
this.note = note;
|
|
3385
|
+
this.taskId = task.id;
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3388
|
+
// use WeakMap here to make the Test and Suite object serializable
|
|
3389
|
+
const fnMap = new WeakMap();
|
|
3390
|
+
const testFixtureMap = new WeakMap();
|
|
3391
|
+
const hooksMap = new WeakMap();
|
|
3392
|
+
function setFn(key, fn) {
|
|
3393
|
+
fnMap.set(key, fn);
|
|
3394
|
+
}
|
|
3395
|
+
function setTestFixture(key, fixture) {
|
|
3396
|
+
testFixtureMap.set(key, fixture);
|
|
3397
|
+
}
|
|
3398
|
+
function getTestFixture(key) {
|
|
3399
|
+
return testFixtureMap.get(key);
|
|
3400
|
+
}
|
|
3401
|
+
function setHooks(key, hooks) {
|
|
3402
|
+
hooksMap.set(key, hooks);
|
|
3403
|
+
}
|
|
3404
|
+
function getHooks(key) {
|
|
3405
|
+
return hooksMap.get(key);
|
|
3406
|
+
}
|
|
3407
|
+
function mergeScopedFixtures(testFixtures, scopedFixtures) {
|
|
3408
|
+
const scopedFixturesMap = scopedFixtures.reduce((map, fixture)=>{
|
|
3409
|
+
map[fixture.prop] = fixture;
|
|
3410
|
+
return map;
|
|
3411
|
+
}, {});
|
|
3412
|
+
const newFixtures = {};
|
|
3413
|
+
testFixtures.forEach((fixture)=>{
|
|
3414
|
+
const useFixture = scopedFixturesMap[fixture.prop] || {
|
|
3415
|
+
...fixture
|
|
3416
|
+
};
|
|
3417
|
+
newFixtures[useFixture.prop] = useFixture;
|
|
3418
|
+
});
|
|
3419
|
+
for(const fixtureKep in newFixtures){
|
|
3420
|
+
var _fixture$deps;
|
|
3421
|
+
const fixture = newFixtures[fixtureKep];
|
|
3422
|
+
// if the fixture was define before the scope, then its dep
|
|
3423
|
+
// will reference the original fixture instead of the scope
|
|
3424
|
+
fixture.deps = (_fixture$deps = fixture.deps) === null || _fixture$deps === void 0 ? void 0 : _fixture$deps.map((dep)=>newFixtures[dep.prop]);
|
|
3425
|
+
}
|
|
3426
|
+
return Object.values(newFixtures);
|
|
3427
|
+
}
|
|
3428
|
+
function mergeContextFixtures(fixtures, context, runner) {
|
|
3429
|
+
const fixtureOptionKeys = [
|
|
3430
|
+
"auto",
|
|
3431
|
+
"injected",
|
|
3432
|
+
"scope"
|
|
3433
|
+
];
|
|
3434
|
+
const fixtureArray = Object.entries(fixtures).map(([prop, value])=>{
|
|
3435
|
+
const fixtureItem = {
|
|
3436
|
+
value
|
|
3437
|
+
};
|
|
3438
|
+
if (Array.isArray(value) && value.length >= 2 && isObject(value[1]) && Object.keys(value[1]).some((key)=>fixtureOptionKeys.includes(key))) {
|
|
3439
|
+
var _runner$injectValue;
|
|
3440
|
+
// fixture with options
|
|
3441
|
+
Object.assign(fixtureItem, value[1]);
|
|
3442
|
+
const userValue = value[0];
|
|
3443
|
+
fixtureItem.value = fixtureItem.injected ? ((_runner$injectValue = runner.injectValue) === null || _runner$injectValue === void 0 ? void 0 : _runner$injectValue.call(runner, prop)) ?? userValue : userValue;
|
|
3444
|
+
}
|
|
3445
|
+
fixtureItem.scope = fixtureItem.scope || "test";
|
|
3446
|
+
if (fixtureItem.scope === "worker" && !runner.getWorkerContext) {
|
|
3447
|
+
fixtureItem.scope = "file";
|
|
3448
|
+
}
|
|
3449
|
+
fixtureItem.prop = prop;
|
|
3450
|
+
fixtureItem.isFn = typeof fixtureItem.value === "function";
|
|
3451
|
+
return fixtureItem;
|
|
3452
|
+
});
|
|
3453
|
+
if (Array.isArray(context.fixtures)) {
|
|
3454
|
+
context.fixtures = context.fixtures.concat(fixtureArray);
|
|
3455
|
+
} else {
|
|
3456
|
+
context.fixtures = fixtureArray;
|
|
3457
|
+
}
|
|
3458
|
+
// Update dependencies of fixture functions
|
|
3459
|
+
fixtureArray.forEach((fixture)=>{
|
|
3460
|
+
if (fixture.isFn) {
|
|
3461
|
+
const usedProps = getUsedProps(fixture.value);
|
|
3462
|
+
if (usedProps.length) {
|
|
3463
|
+
fixture.deps = context.fixtures.filter(({ prop })=>prop !== fixture.prop && usedProps.includes(prop));
|
|
3464
|
+
}
|
|
3465
|
+
// test can access anything, so we ignore it
|
|
3466
|
+
if (fixture.scope !== "test") {
|
|
3467
|
+
var _fixture$deps2;
|
|
3468
|
+
(_fixture$deps2 = fixture.deps) === null || _fixture$deps2 === void 0 ? void 0 : _fixture$deps2.forEach((dep)=>{
|
|
3469
|
+
if (!dep.isFn) {
|
|
3470
|
+
// non fn fixtures are always resolved and available to anyone
|
|
3471
|
+
return;
|
|
3472
|
+
}
|
|
3473
|
+
// worker scope can only import from worker scope
|
|
3474
|
+
if (fixture.scope === "worker" && dep.scope === "worker") {
|
|
3475
|
+
return;
|
|
3476
|
+
}
|
|
3477
|
+
// file scope an import from file and worker scopes
|
|
3478
|
+
if (fixture.scope === "file" && dep.scope !== "test") {
|
|
3479
|
+
return;
|
|
3480
|
+
}
|
|
3481
|
+
throw new SyntaxError(`cannot use the ${dep.scope} fixture "${dep.prop}" inside the ${fixture.scope} fixture "${fixture.prop}"`);
|
|
3482
|
+
});
|
|
3483
|
+
}
|
|
3484
|
+
}
|
|
3485
|
+
});
|
|
3486
|
+
return context;
|
|
3487
|
+
}
|
|
3488
|
+
const fixtureValueMaps = new Map();
|
|
3489
|
+
const cleanupFnArrayMap = new Map();
|
|
3490
|
+
function withFixtures(runner, fn, testContext) {
|
|
3491
|
+
return (hookContext)=>{
|
|
3492
|
+
const context = hookContext || testContext;
|
|
3493
|
+
if (!context) {
|
|
3494
|
+
return fn({});
|
|
3495
|
+
}
|
|
3496
|
+
const fixtures = getTestFixture(context);
|
|
3497
|
+
if (!(fixtures === null || fixtures === void 0 ? void 0 : fixtures.length)) {
|
|
3498
|
+
return fn(context);
|
|
3499
|
+
}
|
|
3500
|
+
const usedProps = getUsedProps(fn);
|
|
3501
|
+
const hasAutoFixture = fixtures.some(({ auto })=>auto);
|
|
3502
|
+
if (!usedProps.length && !hasAutoFixture) {
|
|
3503
|
+
return fn(context);
|
|
3504
|
+
}
|
|
3505
|
+
if (!fixtureValueMaps.get(context)) {
|
|
3506
|
+
fixtureValueMaps.set(context, new Map());
|
|
3507
|
+
}
|
|
3508
|
+
const fixtureValueMap = fixtureValueMaps.get(context);
|
|
3509
|
+
if (!cleanupFnArrayMap.has(context)) {
|
|
3510
|
+
cleanupFnArrayMap.set(context, []);
|
|
3511
|
+
}
|
|
3512
|
+
const cleanupFnArray = cleanupFnArrayMap.get(context);
|
|
3513
|
+
const usedFixtures = fixtures.filter(({ prop, auto })=>auto || usedProps.includes(prop));
|
|
3514
|
+
const pendingFixtures = resolveDeps(usedFixtures);
|
|
3515
|
+
if (!pendingFixtures.length) {
|
|
3516
|
+
return fn(context);
|
|
3517
|
+
}
|
|
3518
|
+
async function resolveFixtures() {
|
|
3519
|
+
for (const fixture of pendingFixtures){
|
|
3520
|
+
// fixture could be already initialized during "before" hook
|
|
3521
|
+
if (fixtureValueMap.has(fixture)) {
|
|
3522
|
+
continue;
|
|
3523
|
+
}
|
|
3524
|
+
const resolvedValue = await resolveFixtureValue(runner, fixture, context, cleanupFnArray);
|
|
3525
|
+
context[fixture.prop] = resolvedValue;
|
|
3526
|
+
fixtureValueMap.set(fixture, resolvedValue);
|
|
3527
|
+
if (fixture.scope === "test") {
|
|
3528
|
+
cleanupFnArray.unshift(()=>{
|
|
3529
|
+
fixtureValueMap.delete(fixture);
|
|
3530
|
+
});
|
|
3531
|
+
}
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
return resolveFixtures().then(()=>fn(context));
|
|
3535
|
+
};
|
|
3536
|
+
}
|
|
3537
|
+
const globalFixturePromise = new WeakMap();
|
|
3538
|
+
function resolveFixtureValue(runner, fixture, context, cleanupFnArray) {
|
|
3539
|
+
var _runner$getWorkerCont;
|
|
3540
|
+
const fileContext = getFileContext(context.task.file);
|
|
3541
|
+
const workerContext = (_runner$getWorkerCont = runner.getWorkerContext) === null || _runner$getWorkerCont === void 0 ? void 0 : _runner$getWorkerCont.call(runner);
|
|
3542
|
+
if (!fixture.isFn) {
|
|
3543
|
+
var _fixture$prop;
|
|
3544
|
+
fileContext[_fixture$prop = fixture.prop] ?? (fileContext[_fixture$prop] = fixture.value);
|
|
3545
|
+
if (workerContext) {
|
|
3546
|
+
var _fixture$prop2;
|
|
3547
|
+
workerContext[_fixture$prop2 = fixture.prop] ?? (workerContext[_fixture$prop2] = fixture.value);
|
|
3548
|
+
}
|
|
3549
|
+
return fixture.value;
|
|
3550
|
+
}
|
|
3551
|
+
if (fixture.scope === "test") {
|
|
3552
|
+
return resolveFixtureFunction(fixture.value, context, cleanupFnArray);
|
|
3553
|
+
}
|
|
3554
|
+
// in case the test runs in parallel
|
|
3555
|
+
if (globalFixturePromise.has(fixture)) {
|
|
3556
|
+
return globalFixturePromise.get(fixture);
|
|
3557
|
+
}
|
|
3558
|
+
let fixtureContext;
|
|
3559
|
+
if (fixture.scope === "worker") {
|
|
3560
|
+
if (!workerContext) {
|
|
3561
|
+
throw new TypeError("[@vitest/runner] The worker context is not available in the current test runner. Please, provide the `getWorkerContext` method when initiating the runner.");
|
|
3562
|
+
}
|
|
3563
|
+
fixtureContext = workerContext;
|
|
3564
|
+
} else {
|
|
3565
|
+
fixtureContext = fileContext;
|
|
3566
|
+
}
|
|
3567
|
+
if (fixture.prop in fixtureContext) {
|
|
3568
|
+
return fixtureContext[fixture.prop];
|
|
3569
|
+
}
|
|
3570
|
+
if (!cleanupFnArrayMap.has(fixtureContext)) {
|
|
3571
|
+
cleanupFnArrayMap.set(fixtureContext, []);
|
|
3572
|
+
}
|
|
3573
|
+
const cleanupFnFileArray = cleanupFnArrayMap.get(fixtureContext);
|
|
3574
|
+
const promise = resolveFixtureFunction(fixture.value, fixtureContext, cleanupFnFileArray).then((value)=>{
|
|
3575
|
+
fixtureContext[fixture.prop] = value;
|
|
3576
|
+
globalFixturePromise.delete(fixture);
|
|
3577
|
+
return value;
|
|
3578
|
+
});
|
|
3579
|
+
globalFixturePromise.set(fixture, promise);
|
|
3580
|
+
return promise;
|
|
3581
|
+
}
|
|
3582
|
+
async function resolveFixtureFunction(fixtureFn, context, cleanupFnArray) {
|
|
3583
|
+
// wait for `use` call to extract fixture value
|
|
3584
|
+
const useFnArgPromise = createDefer();
|
|
3585
|
+
let isUseFnArgResolved = false;
|
|
3586
|
+
const fixtureReturn = fixtureFn(context, async (useFnArg)=>{
|
|
3587
|
+
// extract `use` argument
|
|
3588
|
+
isUseFnArgResolved = true;
|
|
3589
|
+
useFnArgPromise.resolve(useFnArg);
|
|
3590
|
+
// suspend fixture teardown by holding off `useReturnPromise` resolution until cleanup
|
|
3591
|
+
const useReturnPromise = createDefer();
|
|
3592
|
+
cleanupFnArray.push(async ()=>{
|
|
3593
|
+
// start teardown by resolving `use` Promise
|
|
3594
|
+
useReturnPromise.resolve();
|
|
3595
|
+
// wait for finishing teardown
|
|
3596
|
+
await fixtureReturn;
|
|
3597
|
+
});
|
|
3598
|
+
await useReturnPromise;
|
|
3599
|
+
}).catch((e)=>{
|
|
3600
|
+
// treat fixture setup error as test failure
|
|
3601
|
+
if (!isUseFnArgResolved) {
|
|
3602
|
+
useFnArgPromise.reject(e);
|
|
3603
|
+
return;
|
|
3604
|
+
}
|
|
3605
|
+
// otherwise re-throw to avoid silencing error during cleanup
|
|
3606
|
+
throw e;
|
|
3607
|
+
});
|
|
3608
|
+
return useFnArgPromise;
|
|
3609
|
+
}
|
|
3610
|
+
function resolveDeps(fixtures, depSet = new Set(), pendingFixtures = []) {
|
|
3611
|
+
fixtures.forEach((fixture)=>{
|
|
3612
|
+
if (pendingFixtures.includes(fixture)) {
|
|
3613
|
+
return;
|
|
3614
|
+
}
|
|
3615
|
+
if (!fixture.isFn || !fixture.deps) {
|
|
3616
|
+
pendingFixtures.push(fixture);
|
|
3617
|
+
return;
|
|
3618
|
+
}
|
|
3619
|
+
if (depSet.has(fixture)) {
|
|
3620
|
+
throw new Error(`Circular fixture dependency detected: ${fixture.prop} <- ${[
|
|
3621
|
+
...depSet
|
|
3622
|
+
].reverse().map((d)=>d.prop).join(" <- ")}`);
|
|
3623
|
+
}
|
|
3624
|
+
depSet.add(fixture);
|
|
3625
|
+
resolveDeps(fixture.deps, depSet, pendingFixtures);
|
|
3626
|
+
pendingFixtures.push(fixture);
|
|
3627
|
+
depSet.clear();
|
|
3628
|
+
});
|
|
3629
|
+
return pendingFixtures;
|
|
3630
|
+
}
|
|
3631
|
+
function getUsedProps(fn) {
|
|
3632
|
+
let fnString = filterOutComments(fn.toString());
|
|
3633
|
+
// match lowered async function and strip it off
|
|
3634
|
+
// example code on esbuild-try https://esbuild.github.io/try/#YgAwLjI0LjAALS1zdXBwb3J0ZWQ6YXN5bmMtYXdhaXQ9ZmFsc2UAZQBlbnRyeS50cwBjb25zdCBvID0gewogIGYxOiBhc3luYyAoKSA9PiB7fSwKICBmMjogYXN5bmMgKGEpID0+IHt9LAogIGYzOiBhc3luYyAoYSwgYikgPT4ge30sCiAgZjQ6IGFzeW5jIGZ1bmN0aW9uKGEpIHt9LAogIGY1OiBhc3luYyBmdW5jdGlvbiBmZihhKSB7fSwKICBhc3luYyBmNihhKSB7fSwKCiAgZzE6IGFzeW5jICgpID0+IHt9LAogIGcyOiBhc3luYyAoeyBhIH0pID0+IHt9LAogIGczOiBhc3luYyAoeyBhIH0sIGIpID0+IHt9LAogIGc0OiBhc3luYyBmdW5jdGlvbiAoeyBhIH0pIHt9LAogIGc1OiBhc3luYyBmdW5jdGlvbiBnZyh7IGEgfSkge30sCiAgYXN5bmMgZzYoeyBhIH0pIHt9LAoKICBoMTogYXN5bmMgKCkgPT4ge30sCiAgLy8gY29tbWVudCBiZXR3ZWVuCiAgaDI6IGFzeW5jIChhKSA9PiB7fSwKfQ
|
|
3635
|
+
// __async(this, null, function*
|
|
3636
|
+
// __async(this, arguments, function*
|
|
3637
|
+
// __async(this, [_0, _1], function*
|
|
3638
|
+
if (/__async\((?:this|null), (?:null|arguments|\[[_0-9, ]*\]), function\*/.test(fnString)) {
|
|
3639
|
+
fnString = fnString.split(/__async\((?:this|null),/)[1];
|
|
3640
|
+
}
|
|
3641
|
+
const match = fnString.match(/[^(]*\(([^)]*)/);
|
|
3642
|
+
if (!match) {
|
|
3643
|
+
return [];
|
|
3644
|
+
}
|
|
3645
|
+
const args = splitByComma(match[1]);
|
|
3646
|
+
if (!args.length) {
|
|
3647
|
+
return [];
|
|
3648
|
+
}
|
|
3649
|
+
let first = args[0];
|
|
3650
|
+
if ("__VITEST_FIXTURE_INDEX__" in fn) {
|
|
3651
|
+
first = args[fn.__VITEST_FIXTURE_INDEX__];
|
|
3652
|
+
if (!first) {
|
|
3653
|
+
return [];
|
|
3654
|
+
}
|
|
3655
|
+
}
|
|
3656
|
+
if (!(first[0] === "{" && first.endsWith("}"))) {
|
|
3657
|
+
throw new Error(`The first argument inside a fixture must use object destructuring pattern, e.g. ({ test } => {}). Instead, received "${first}".`);
|
|
3658
|
+
}
|
|
3659
|
+
const _first = first.slice(1, -1).replace(/\s/g, "");
|
|
3660
|
+
const props = splitByComma(_first).map((prop)=>{
|
|
3661
|
+
return prop.replace(/:.*|=.*/g, "");
|
|
3662
|
+
});
|
|
3663
|
+
const last = props.at(-1);
|
|
3664
|
+
if (last && last.startsWith("...")) {
|
|
3665
|
+
throw new Error(`Rest parameters are not supported in fixtures, received "${last}".`);
|
|
3666
|
+
}
|
|
3667
|
+
return props;
|
|
3668
|
+
}
|
|
3669
|
+
function filterOutComments(s) {
|
|
3670
|
+
const result = [];
|
|
3671
|
+
let commentState = "none";
|
|
3672
|
+
for(let i = 0; i < s.length; ++i){
|
|
3673
|
+
if (commentState === "singleline") {
|
|
3674
|
+
if (s[i] === "\n") {
|
|
3675
|
+
commentState = "none";
|
|
3676
|
+
}
|
|
3677
|
+
} else if (commentState === "multiline") {
|
|
3678
|
+
if (s[i - 1] === "*" && s[i] === "/") {
|
|
3679
|
+
commentState = "none";
|
|
3680
|
+
}
|
|
3681
|
+
} else if (commentState === "none") {
|
|
3682
|
+
if (s[i] === "/" && s[i + 1] === "/") {
|
|
3683
|
+
commentState = "singleline";
|
|
3684
|
+
} else if (s[i] === "/" && s[i + 1] === "*") {
|
|
3685
|
+
commentState = "multiline";
|
|
3686
|
+
i += 2;
|
|
3687
|
+
} else {
|
|
3688
|
+
result.push(s[i]);
|
|
3689
|
+
}
|
|
3690
|
+
}
|
|
3691
|
+
}
|
|
3692
|
+
return result.join("");
|
|
3693
|
+
}
|
|
3694
|
+
function splitByComma(s) {
|
|
3695
|
+
const result = [];
|
|
3696
|
+
const stack = [];
|
|
3697
|
+
let start = 0;
|
|
3698
|
+
for(let i = 0; i < s.length; i++){
|
|
3699
|
+
if (s[i] === "{" || s[i] === "[") {
|
|
3700
|
+
stack.push(s[i] === "{" ? "}" : "]");
|
|
3701
|
+
} else if (s[i] === stack.at(-1)) {
|
|
3702
|
+
stack.pop();
|
|
3703
|
+
} else if (!stack.length && s[i] === ",") {
|
|
3704
|
+
const token = s.substring(start, i).trim();
|
|
3705
|
+
if (token) {
|
|
3706
|
+
result.push(token);
|
|
3707
|
+
}
|
|
3708
|
+
start = i + 1;
|
|
3709
|
+
}
|
|
3710
|
+
}
|
|
3711
|
+
const lastToken = s.substring(start).trim();
|
|
3712
|
+
if (lastToken) {
|
|
3713
|
+
result.push(lastToken);
|
|
3714
|
+
}
|
|
3715
|
+
return result;
|
|
3716
|
+
}
|
|
3717
|
+
function getDefaultHookTimeout() {
|
|
3718
|
+
return getRunner().config.hookTimeout;
|
|
3719
|
+
}
|
|
3720
|
+
const CLEANUP_TIMEOUT_KEY = Symbol.for("VITEST_CLEANUP_TIMEOUT");
|
|
3721
|
+
const CLEANUP_STACK_TRACE_KEY = Symbol.for("VITEST_CLEANUP_STACK_TRACE");
|
|
3722
|
+
/**
|
|
3723
|
+
* Registers a callback function to be executed once before all tests within the current suite.
|
|
3724
|
+
* This hook is useful for scenarios where you need to perform setup operations that are common to all tests in a suite, such as initializing a database connection or setting up a test environment.
|
|
3725
|
+
*
|
|
3726
|
+
* **Note:** The `beforeAll` hooks are executed in the order they are defined one after another. You can configure this by changing the `sequence.hooks` option in the config file.
|
|
3727
|
+
*
|
|
3728
|
+
* @param {Function} fn - The callback function to be executed before all tests.
|
|
3729
|
+
* @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
|
|
3730
|
+
* @returns {void}
|
|
3731
|
+
* @example
|
|
3732
|
+
* ```ts
|
|
3733
|
+
* // Example of using beforeAll to set up a database connection
|
|
3734
|
+
* beforeAll(async () => {
|
|
3735
|
+
* await database.connect();
|
|
3736
|
+
* });
|
|
3737
|
+
* ```
|
|
3738
|
+
*/ function beforeAll(fn, timeout = getDefaultHookTimeout()) {
|
|
3739
|
+
assertTypes(fn, "\"beforeAll\" callback", [
|
|
3740
|
+
"function"
|
|
3741
|
+
]);
|
|
3742
|
+
const stackTraceError = new Error("STACK_TRACE_ERROR");
|
|
3743
|
+
return getCurrentSuite().on("beforeAll", Object.assign(withTimeout(fn, timeout, true, stackTraceError), {
|
|
3744
|
+
[CLEANUP_TIMEOUT_KEY]: timeout,
|
|
3745
|
+
[CLEANUP_STACK_TRACE_KEY]: stackTraceError
|
|
3746
|
+
}));
|
|
3747
|
+
}
|
|
3748
|
+
/**
|
|
3749
|
+
* Registers a callback function to be executed once after all tests within the current suite have completed.
|
|
3750
|
+
* This hook is useful for scenarios where you need to perform cleanup operations after all tests in a suite have run, such as closing database connections or cleaning up temporary files.
|
|
3751
|
+
*
|
|
3752
|
+
* **Note:** The `afterAll` hooks are running in reverse order of their registration. You can configure this by changing the `sequence.hooks` option in the config file.
|
|
3753
|
+
*
|
|
3754
|
+
* @param {Function} fn - The callback function to be executed after all tests.
|
|
3755
|
+
* @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
|
|
3756
|
+
* @returns {void}
|
|
3757
|
+
* @example
|
|
3758
|
+
* ```ts
|
|
3759
|
+
* // Example of using afterAll to close a database connection
|
|
3760
|
+
* afterAll(async () => {
|
|
3761
|
+
* await database.disconnect();
|
|
3762
|
+
* });
|
|
3763
|
+
* ```
|
|
3764
|
+
*/ function afterAll(fn, timeout) {
|
|
3765
|
+
assertTypes(fn, "\"afterAll\" callback", [
|
|
3766
|
+
"function"
|
|
3767
|
+
]);
|
|
3768
|
+
return getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR")));
|
|
3769
|
+
}
|
|
3770
|
+
/**
|
|
3771
|
+
* Registers a callback function to be executed before each test within the current suite.
|
|
3772
|
+
* This hook is useful for scenarios where you need to reset or reinitialize the test environment before each test runs, such as resetting database states, clearing caches, or reinitializing variables.
|
|
3773
|
+
*
|
|
3774
|
+
* **Note:** The `beforeEach` hooks are executed in the order they are defined one after another. You can configure this by changing the `sequence.hooks` option in the config file.
|
|
3775
|
+
*
|
|
3776
|
+
* @param {Function} fn - The callback function to be executed before each test. This function receives an `TestContext` parameter if additional test context is needed.
|
|
3777
|
+
* @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
|
|
3778
|
+
* @returns {void}
|
|
3779
|
+
* @example
|
|
3780
|
+
* ```ts
|
|
3781
|
+
* // Example of using beforeEach to reset a database state
|
|
3782
|
+
* beforeEach(async () => {
|
|
3783
|
+
* await database.reset();
|
|
3784
|
+
* });
|
|
3785
|
+
* ```
|
|
3786
|
+
*/ function beforeEach(fn, timeout = getDefaultHookTimeout()) {
|
|
3787
|
+
assertTypes(fn, "\"beforeEach\" callback", [
|
|
3788
|
+
"function"
|
|
3789
|
+
]);
|
|
3790
|
+
const stackTraceError = new Error("STACK_TRACE_ERROR");
|
|
3791
|
+
const runner = getRunner();
|
|
3792
|
+
return getCurrentSuite().on("beforeEach", Object.assign(withTimeout(withFixtures(runner, fn), timeout ?? getDefaultHookTimeout(), true, stackTraceError, abortIfTimeout), {
|
|
3793
|
+
[CLEANUP_TIMEOUT_KEY]: timeout,
|
|
3794
|
+
[CLEANUP_STACK_TRACE_KEY]: stackTraceError
|
|
3795
|
+
}));
|
|
3796
|
+
}
|
|
3797
|
+
/**
|
|
3798
|
+
* Registers a callback function to be executed after each test within the current suite has completed.
|
|
3799
|
+
* This hook is useful for scenarios where you need to clean up or reset the test environment after each test runs, such as deleting temporary files, clearing test-specific database entries, or resetting mocked functions.
|
|
3800
|
+
*
|
|
3801
|
+
* **Note:** The `afterEach` hooks are running in reverse order of their registration. You can configure this by changing the `sequence.hooks` option in the config file.
|
|
3802
|
+
*
|
|
3803
|
+
* @param {Function} fn - The callback function to be executed after each test. This function receives an `TestContext` parameter if additional test context is needed.
|
|
3804
|
+
* @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
|
|
3805
|
+
* @returns {void}
|
|
3806
|
+
* @example
|
|
3807
|
+
* ```ts
|
|
3808
|
+
* // Example of using afterEach to delete temporary files created during a test
|
|
3809
|
+
* afterEach(async () => {
|
|
3810
|
+
* await fileSystem.deleteTempFiles();
|
|
3811
|
+
* });
|
|
3812
|
+
* ```
|
|
3813
|
+
*/ function afterEach(fn, timeout) {
|
|
3814
|
+
assertTypes(fn, "\"afterEach\" callback", [
|
|
3815
|
+
"function"
|
|
3816
|
+
]);
|
|
3817
|
+
const runner = getRunner();
|
|
3818
|
+
return getCurrentSuite().on("afterEach", withTimeout(withFixtures(runner, fn), timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
|
|
3819
|
+
}
|
|
3820
|
+
/**
|
|
3821
|
+
* Creates a suite of tests, allowing for grouping and hierarchical organization of tests.
|
|
3822
|
+
* Suites can contain both tests and other suites, enabling complex test structures.
|
|
3823
|
+
*
|
|
3824
|
+
* @param {string} name - The name of the suite, used for identification and reporting.
|
|
3825
|
+
* @param {Function} fn - A function that defines the tests and suites within this suite.
|
|
3826
|
+
* @example
|
|
3827
|
+
* ```ts
|
|
3828
|
+
* // Define a suite with two tests
|
|
3829
|
+
* suite('Math operations', () => {
|
|
3830
|
+
* test('should add two numbers', () => {
|
|
3831
|
+
* expect(add(1, 2)).toBe(3);
|
|
3832
|
+
* });
|
|
3833
|
+
*
|
|
3834
|
+
* test('should subtract two numbers', () => {
|
|
3835
|
+
* expect(subtract(5, 2)).toBe(3);
|
|
3836
|
+
* });
|
|
3837
|
+
* });
|
|
3838
|
+
* ```
|
|
3839
|
+
* @example
|
|
3840
|
+
* ```ts
|
|
3841
|
+
* // Define nested suites
|
|
3842
|
+
* suite('String operations', () => {
|
|
3843
|
+
* suite('Trimming', () => {
|
|
3844
|
+
* test('should trim whitespace from start and end', () => {
|
|
3845
|
+
* expect(' hello '.trim()).toBe('hello');
|
|
3846
|
+
* });
|
|
3847
|
+
* });
|
|
3848
|
+
*
|
|
3849
|
+
* suite('Concatenation', () => {
|
|
3850
|
+
* test('should concatenate two strings', () => {
|
|
3851
|
+
* expect('hello' + ' ' + 'world').toBe('hello world');
|
|
3852
|
+
* });
|
|
3853
|
+
* });
|
|
3854
|
+
* });
|
|
3855
|
+
* ```
|
|
3856
|
+
*/ const suite = createSuite();
|
|
3857
|
+
/**
|
|
3858
|
+
* Defines a test case with a given name and test function. The test function can optionally be configured with test options.
|
|
3859
|
+
*
|
|
3860
|
+
* @param {string | Function} name - The name of the test or a function that will be used as a test name.
|
|
3861
|
+
* @param {TestOptions | TestFunction} [optionsOrFn] - Optional. The test options or the test function if no explicit name is provided.
|
|
3862
|
+
* @param {number | TestOptions | TestFunction} [optionsOrTest] - Optional. The test function or options, depending on the previous parameters.
|
|
3863
|
+
* @throws {Error} If called inside another test function.
|
|
3864
|
+
* @example
|
|
3865
|
+
* ```ts
|
|
3866
|
+
* // Define a simple test
|
|
3867
|
+
* test('should add two numbers', () => {
|
|
3868
|
+
* expect(add(1, 2)).toBe(3);
|
|
3869
|
+
* });
|
|
3870
|
+
* ```
|
|
3871
|
+
* @example
|
|
3872
|
+
* ```ts
|
|
3873
|
+
* // Define a test with options
|
|
3874
|
+
* test('should subtract two numbers', { retry: 3 }, () => {
|
|
3875
|
+
* expect(subtract(5, 2)).toBe(3);
|
|
3876
|
+
* });
|
|
3877
|
+
* ```
|
|
3878
|
+
*/ const test = createTest(function(name, optionsOrFn, optionsOrTest) {
|
|
3879
|
+
getCurrentSuite().test.fn.call(this, formatName(name), optionsOrFn, optionsOrTest);
|
|
3880
|
+
});
|
|
3881
|
+
/**
|
|
3882
|
+
* Creates a suite of tests, allowing for grouping and hierarchical organization of tests.
|
|
3883
|
+
* Suites can contain both tests and other suites, enabling complex test structures.
|
|
3884
|
+
*
|
|
3885
|
+
* @param {string} name - The name of the suite, used for identification and reporting.
|
|
3886
|
+
* @param {Function} fn - A function that defines the tests and suites within this suite.
|
|
3887
|
+
* @example
|
|
3888
|
+
* ```ts
|
|
3889
|
+
* // Define a suite with two tests
|
|
3890
|
+
* describe('Math operations', () => {
|
|
3891
|
+
* test('should add two numbers', () => {
|
|
3892
|
+
* expect(add(1, 2)).toBe(3);
|
|
3893
|
+
* });
|
|
3894
|
+
*
|
|
3895
|
+
* test('should subtract two numbers', () => {
|
|
3896
|
+
* expect(subtract(5, 2)).toBe(3);
|
|
3897
|
+
* });
|
|
3898
|
+
* });
|
|
3899
|
+
* ```
|
|
3900
|
+
* @example
|
|
3901
|
+
* ```ts
|
|
3902
|
+
* // Define nested suites
|
|
3903
|
+
* describe('String operations', () => {
|
|
3904
|
+
* describe('Trimming', () => {
|
|
3905
|
+
* test('should trim whitespace from start and end', () => {
|
|
3906
|
+
* expect(' hello '.trim()).toBe('hello');
|
|
3907
|
+
* });
|
|
3908
|
+
* });
|
|
3909
|
+
*
|
|
3910
|
+
* describe('Concatenation', () => {
|
|
3911
|
+
* test('should concatenate two strings', () => {
|
|
3912
|
+
* expect('hello' + ' ' + 'world').toBe('hello world');
|
|
3913
|
+
* });
|
|
3914
|
+
* });
|
|
3915
|
+
* });
|
|
3916
|
+
* ```
|
|
3917
|
+
*/ const describe = suite;
|
|
3918
|
+
/**
|
|
3919
|
+
* Defines a test case with a given name and test function. The test function can optionally be configured with test options.
|
|
3920
|
+
*
|
|
3921
|
+
* @param {string | Function} name - The name of the test or a function that will be used as a test name.
|
|
3922
|
+
* @param {TestOptions | TestFunction} [optionsOrFn] - Optional. The test options or the test function if no explicit name is provided.
|
|
3923
|
+
* @param {number | TestOptions | TestFunction} [optionsOrTest] - Optional. The test function or options, depending on the previous parameters.
|
|
3924
|
+
* @throws {Error} If called inside another test function.
|
|
3925
|
+
* @example
|
|
3926
|
+
* ```ts
|
|
3927
|
+
* // Define a simple test
|
|
3928
|
+
* it('adds two numbers', () => {
|
|
3929
|
+
* expect(add(1, 2)).toBe(3);
|
|
3930
|
+
* });
|
|
3931
|
+
* ```
|
|
3932
|
+
* @example
|
|
3933
|
+
* ```ts
|
|
3934
|
+
* // Define a test with options
|
|
3935
|
+
* it('subtracts two numbers', { retry: 3 }, () => {
|
|
3936
|
+
* expect(subtract(5, 2)).toBe(3);
|
|
3937
|
+
* });
|
|
3938
|
+
* ```
|
|
3939
|
+
*/ const it = test;
|
|
3940
|
+
let runner;
|
|
3941
|
+
let defaultSuite;
|
|
3942
|
+
let currentTestFilepath;
|
|
3943
|
+
function assert(condition, message) {
|
|
3944
|
+
if (!condition) {
|
|
3945
|
+
throw new Error(`Vitest failed to find ${message}. One of the following is possible:` + "\n- \"vitest\" is imported directly without running \"vitest\" command" + "\n- \"vitest\" is imported inside \"globalSetup\" (to fix this, use \"setupFiles\" instead, because \"globalSetup\" runs in a different context)" + "\n- \"vitest\" is imported inside Vite / Vitest config file" + "\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n");
|
|
3946
|
+
}
|
|
3947
|
+
}
|
|
3948
|
+
function getRunner() {
|
|
3949
|
+
assert(runner, "the runner");
|
|
3950
|
+
return runner;
|
|
3951
|
+
}
|
|
3952
|
+
function getCurrentSuite() {
|
|
3953
|
+
const currentSuite = collectorContext.currentSuite || defaultSuite;
|
|
3954
|
+
assert(currentSuite, "the current suite");
|
|
3955
|
+
return currentSuite;
|
|
3956
|
+
}
|
|
3957
|
+
function createSuiteHooks() {
|
|
3958
|
+
return {
|
|
3959
|
+
beforeAll: [],
|
|
3960
|
+
afterAll: [],
|
|
3961
|
+
beforeEach: [],
|
|
3962
|
+
afterEach: []
|
|
3963
|
+
};
|
|
3964
|
+
}
|
|
3965
|
+
function parseArguments(optionsOrFn, timeoutOrTest) {
|
|
3966
|
+
if (timeoutOrTest != null && typeof timeoutOrTest === "object") {
|
|
3967
|
+
throw new TypeError(`Signature "test(name, fn, { ... })" was deprecated in Vitest 3 and removed in Vitest 4. Please, provide options as a second argument instead.`);
|
|
3968
|
+
}
|
|
3969
|
+
let options = {};
|
|
3970
|
+
let fn;
|
|
3971
|
+
// it('', () => {}, 1000)
|
|
3972
|
+
if (typeof timeoutOrTest === "number") {
|
|
3973
|
+
options = {
|
|
3974
|
+
timeout: timeoutOrTest
|
|
3975
|
+
};
|
|
3976
|
+
} else if (typeof optionsOrFn === "object") {
|
|
3977
|
+
options = optionsOrFn;
|
|
3978
|
+
}
|
|
3979
|
+
if (typeof optionsOrFn === "function") {
|
|
3980
|
+
if (typeof timeoutOrTest === "function") {
|
|
3981
|
+
throw new TypeError("Cannot use two functions as arguments. Please use the second argument for options.");
|
|
3982
|
+
}
|
|
3983
|
+
fn = optionsOrFn;
|
|
3984
|
+
} else if (typeof timeoutOrTest === "function") {
|
|
3985
|
+
fn = timeoutOrTest;
|
|
3986
|
+
}
|
|
3987
|
+
return {
|
|
3988
|
+
options,
|
|
3989
|
+
handler: fn
|
|
3990
|
+
};
|
|
3991
|
+
}
|
|
3992
|
+
// implementations
|
|
3993
|
+
function createSuiteCollector(name, factory = ()=>{}, mode, each, suiteOptions, parentCollectorFixtures) {
|
|
3994
|
+
const tasks = [];
|
|
3995
|
+
let suite;
|
|
3996
|
+
initSuite();
|
|
3997
|
+
const task = function(name = "", options = {}) {
|
|
3998
|
+
var _collectorContext$cur, _collectorContext$cur2, _collectorContext$cur3;
|
|
3999
|
+
const timeout = (options === null || options === void 0 ? void 0 : options.timeout) ?? runner.config.testTimeout;
|
|
4000
|
+
const currentSuite = (_collectorContext$cur = collectorContext.currentSuite) === null || _collectorContext$cur === void 0 ? void 0 : _collectorContext$cur.suite;
|
|
4001
|
+
const task = {
|
|
4002
|
+
id: "",
|
|
4003
|
+
name,
|
|
4004
|
+
fullName: createTaskName([
|
|
4005
|
+
(currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fullName) ?? ((_collectorContext$cur2 = collectorContext.currentSuite) === null || _collectorContext$cur2 === void 0 || (_collectorContext$cur2 = _collectorContext$cur2.file) === null || _collectorContext$cur2 === void 0 ? void 0 : _collectorContext$cur2.fullName),
|
|
4006
|
+
name
|
|
4007
|
+
]),
|
|
4008
|
+
fullTestName: createTaskName([
|
|
4009
|
+
currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fullTestName,
|
|
4010
|
+
name
|
|
4011
|
+
]),
|
|
4012
|
+
suite: currentSuite,
|
|
4013
|
+
each: options.each,
|
|
4014
|
+
fails: options.fails,
|
|
4015
|
+
context: undefined,
|
|
4016
|
+
type: "test",
|
|
4017
|
+
file: (currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.file) ?? ((_collectorContext$cur3 = collectorContext.currentSuite) === null || _collectorContext$cur3 === void 0 ? void 0 : _collectorContext$cur3.file),
|
|
4018
|
+
timeout,
|
|
4019
|
+
retry: options.retry ?? runner.config.retry,
|
|
4020
|
+
repeats: options.repeats,
|
|
4021
|
+
mode: options.only ? "only" : options.skip ? "skip" : options.todo ? "todo" : "run",
|
|
4022
|
+
meta: options.meta ?? Object.create(null),
|
|
4023
|
+
annotations: [],
|
|
4024
|
+
artifacts: []
|
|
4025
|
+
};
|
|
4026
|
+
const handler = options.handler;
|
|
4027
|
+
if (task.mode === "run" && !handler) {
|
|
4028
|
+
task.mode = "todo";
|
|
4029
|
+
}
|
|
4030
|
+
if (options.concurrent || !options.sequential && runner.config.sequence.concurrent) {
|
|
4031
|
+
task.concurrent = true;
|
|
4032
|
+
}
|
|
4033
|
+
task.shuffle = suiteOptions === null || suiteOptions === void 0 ? void 0 : suiteOptions.shuffle;
|
|
4034
|
+
const context = createTestContext(task, runner);
|
|
4035
|
+
// create test context
|
|
4036
|
+
Object.defineProperty(task, "context", {
|
|
4037
|
+
value: context,
|
|
4038
|
+
enumerable: false
|
|
4039
|
+
});
|
|
4040
|
+
setTestFixture(context, options.fixtures);
|
|
4041
|
+
// custom can be called from any place, let's assume the limit is 15 stacks
|
|
4042
|
+
const limit = Error.stackTraceLimit;
|
|
4043
|
+
Error.stackTraceLimit = 15;
|
|
4044
|
+
const stackTraceError = new Error("STACK_TRACE_ERROR");
|
|
4045
|
+
Error.stackTraceLimit = limit;
|
|
4046
|
+
if (handler) {
|
|
4047
|
+
setFn(task, withTimeout(withAwaitAsyncAssertions(withFixtures(runner, handler, context), task), timeout, false, stackTraceError, (_, error)=>abortIfTimeout([
|
|
4048
|
+
context
|
|
4049
|
+
], error)));
|
|
4050
|
+
}
|
|
4051
|
+
if (runner.config.includeTaskLocation) {
|
|
4052
|
+
const error = stackTraceError.stack;
|
|
4053
|
+
const stack = findTestFileStackTrace(currentTestFilepath, error);
|
|
4054
|
+
if (stack) {
|
|
4055
|
+
task.location = {
|
|
4056
|
+
line: stack.line,
|
|
4057
|
+
column: stack.column
|
|
4058
|
+
};
|
|
4059
|
+
}
|
|
4060
|
+
}
|
|
4061
|
+
tasks.push(task);
|
|
4062
|
+
return task;
|
|
4063
|
+
};
|
|
4064
|
+
const test = createTest(function(name, optionsOrFn, timeoutOrTest) {
|
|
4065
|
+
let { options, handler } = parseArguments(optionsOrFn, timeoutOrTest);
|
|
4066
|
+
// inherit repeats, retry, timeout from suite
|
|
4067
|
+
if (typeof suiteOptions === "object") {
|
|
4068
|
+
options = Object.assign({}, suiteOptions, options);
|
|
4069
|
+
}
|
|
4070
|
+
// inherit concurrent / sequential from suite
|
|
4071
|
+
options.concurrent = this.concurrent || !this.sequential && (options === null || options === void 0 ? void 0 : options.concurrent);
|
|
4072
|
+
options.sequential = this.sequential || !this.concurrent && (options === null || options === void 0 ? void 0 : options.sequential);
|
|
4073
|
+
const test = task(formatName(name), {
|
|
4074
|
+
...this,
|
|
4075
|
+
...options,
|
|
4076
|
+
handler
|
|
4077
|
+
});
|
|
4078
|
+
test.type = "test";
|
|
4079
|
+
});
|
|
4080
|
+
let collectorFixtures = parentCollectorFixtures;
|
|
4081
|
+
const collector = {
|
|
4082
|
+
type: "collector",
|
|
4083
|
+
name,
|
|
4084
|
+
mode,
|
|
4085
|
+
suite,
|
|
4086
|
+
options: suiteOptions,
|
|
4087
|
+
test,
|
|
4088
|
+
tasks,
|
|
4089
|
+
collect,
|
|
4090
|
+
task,
|
|
4091
|
+
clear,
|
|
4092
|
+
on: addHook,
|
|
4093
|
+
fixtures () {
|
|
4094
|
+
return collectorFixtures;
|
|
4095
|
+
},
|
|
4096
|
+
scoped (fixtures) {
|
|
4097
|
+
const parsed = mergeContextFixtures(fixtures, {
|
|
4098
|
+
fixtures: collectorFixtures
|
|
4099
|
+
}, runner);
|
|
4100
|
+
if (parsed.fixtures) {
|
|
4101
|
+
collectorFixtures = parsed.fixtures;
|
|
4102
|
+
}
|
|
4103
|
+
}
|
|
4104
|
+
};
|
|
4105
|
+
function addHook(name, ...fn) {
|
|
4106
|
+
getHooks(suite)[name].push(...fn);
|
|
4107
|
+
}
|
|
4108
|
+
function initSuite(includeLocation) {
|
|
4109
|
+
var _collectorContext$cur4, _collectorContext$cur5, _collectorContext$cur6;
|
|
4110
|
+
if (typeof suiteOptions === "number") {
|
|
4111
|
+
suiteOptions = {
|
|
4112
|
+
timeout: suiteOptions
|
|
4113
|
+
};
|
|
4114
|
+
}
|
|
4115
|
+
const currentSuite = (_collectorContext$cur4 = collectorContext.currentSuite) === null || _collectorContext$cur4 === void 0 ? void 0 : _collectorContext$cur4.suite;
|
|
4116
|
+
suite = {
|
|
4117
|
+
id: "",
|
|
4118
|
+
type: "suite",
|
|
4119
|
+
name,
|
|
4120
|
+
fullName: createTaskName([
|
|
4121
|
+
(currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fullName) ?? ((_collectorContext$cur5 = collectorContext.currentSuite) === null || _collectorContext$cur5 === void 0 || (_collectorContext$cur5 = _collectorContext$cur5.file) === null || _collectorContext$cur5 === void 0 ? void 0 : _collectorContext$cur5.fullName),
|
|
4122
|
+
name
|
|
4123
|
+
]),
|
|
4124
|
+
fullTestName: createTaskName([
|
|
4125
|
+
currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fullTestName,
|
|
4126
|
+
name
|
|
4127
|
+
]),
|
|
4128
|
+
suite: currentSuite,
|
|
4129
|
+
mode,
|
|
4130
|
+
each,
|
|
4131
|
+
file: (currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.file) ?? ((_collectorContext$cur6 = collectorContext.currentSuite) === null || _collectorContext$cur6 === void 0 ? void 0 : _collectorContext$cur6.file),
|
|
4132
|
+
shuffle: suiteOptions === null || suiteOptions === void 0 ? void 0 : suiteOptions.shuffle,
|
|
4133
|
+
tasks: [],
|
|
4134
|
+
meta: Object.create(null),
|
|
4135
|
+
concurrent: suiteOptions === null || suiteOptions === void 0 ? void 0 : suiteOptions.concurrent
|
|
4136
|
+
};
|
|
4137
|
+
setHooks(suite, createSuiteHooks());
|
|
4138
|
+
}
|
|
4139
|
+
function clear() {
|
|
4140
|
+
tasks.length = 0;
|
|
4141
|
+
initSuite();
|
|
4142
|
+
}
|
|
4143
|
+
async function collect(file) {
|
|
4144
|
+
if (!file) {
|
|
4145
|
+
throw new TypeError("File is required to collect tasks.");
|
|
4146
|
+
}
|
|
4147
|
+
if (factory) {
|
|
4148
|
+
await runWithSuite(collector, ()=>factory(test));
|
|
4149
|
+
}
|
|
4150
|
+
const allChildren = [];
|
|
4151
|
+
for (const i of tasks){
|
|
4152
|
+
allChildren.push(i.type === "collector" ? await i.collect(file) : i);
|
|
4153
|
+
}
|
|
4154
|
+
suite.tasks = allChildren;
|
|
4155
|
+
return suite;
|
|
4156
|
+
}
|
|
4157
|
+
collectTask(collector);
|
|
4158
|
+
return collector;
|
|
4159
|
+
}
|
|
4160
|
+
function withAwaitAsyncAssertions(fn, task) {
|
|
4161
|
+
return async (...args)=>{
|
|
4162
|
+
const fnResult = await fn(...args);
|
|
4163
|
+
// some async expect will be added to this array, in case user forget to await them
|
|
4164
|
+
if (task.promises) {
|
|
4165
|
+
const result = await Promise.allSettled(task.promises);
|
|
4166
|
+
const errors = result.map((r)=>r.status === "rejected" ? r.reason : undefined).filter(Boolean);
|
|
4167
|
+
if (errors.length) {
|
|
4168
|
+
throw errors;
|
|
4169
|
+
}
|
|
4170
|
+
}
|
|
4171
|
+
return fnResult;
|
|
4172
|
+
};
|
|
4173
|
+
}
|
|
4174
|
+
function createSuite() {
|
|
4175
|
+
function suiteFn(name, factoryOrOptions, optionsOrFactory) {
|
|
4176
|
+
var _currentSuite$options;
|
|
4177
|
+
let mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
|
|
4178
|
+
const currentSuite = collectorContext.currentSuite || defaultSuite;
|
|
4179
|
+
let { options, handler: factory } = parseArguments(factoryOrOptions, optionsOrFactory);
|
|
4180
|
+
if (mode === "run" && !factory) {
|
|
4181
|
+
mode = "todo";
|
|
4182
|
+
}
|
|
4183
|
+
const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
|
|
4184
|
+
const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
|
|
4185
|
+
// inherit options from current suite
|
|
4186
|
+
options = {
|
|
4187
|
+
...currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.options,
|
|
4188
|
+
...options,
|
|
4189
|
+
shuffle: this.shuffle ?? options.shuffle ?? (currentSuite === null || currentSuite === void 0 || (_currentSuite$options = currentSuite.options) === null || _currentSuite$options === void 0 ? void 0 : _currentSuite$options.shuffle) ?? (void 0 )
|
|
4190
|
+
};
|
|
4191
|
+
// inherit concurrent / sequential from suite
|
|
4192
|
+
const isConcurrent = isConcurrentSpecified || options.concurrent && !isSequentialSpecified;
|
|
4193
|
+
const isSequential = isSequentialSpecified || options.sequential && !isConcurrentSpecified;
|
|
4194
|
+
options.concurrent = isConcurrent && !isSequential;
|
|
4195
|
+
options.sequential = isSequential && !isConcurrent;
|
|
4196
|
+
return createSuiteCollector(formatName(name), factory, mode, this.each, options, currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fixtures());
|
|
4197
|
+
}
|
|
4198
|
+
suiteFn.each = function(cases, ...args) {
|
|
4199
|
+
const suite = this.withContext();
|
|
4200
|
+
this.setContext("each", true);
|
|
4201
|
+
if (Array.isArray(cases) && args.length) {
|
|
4202
|
+
cases = formatTemplateString(cases, args);
|
|
4203
|
+
}
|
|
4204
|
+
return (name, optionsOrFn, fnOrOptions)=>{
|
|
4205
|
+
const _name = formatName(name);
|
|
4206
|
+
const arrayOnlyCases = cases.every(Array.isArray);
|
|
4207
|
+
const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
|
|
4208
|
+
const fnFirst = typeof optionsOrFn === "function";
|
|
4209
|
+
cases.forEach((i, idx)=>{
|
|
4210
|
+
const items = Array.isArray(i) ? i : [
|
|
4211
|
+
i
|
|
4212
|
+
];
|
|
4213
|
+
if (fnFirst) {
|
|
4214
|
+
if (arrayOnlyCases) {
|
|
4215
|
+
suite(formatTitle(_name, items, idx), handler ? ()=>handler(...items) : undefined, options.timeout);
|
|
4216
|
+
} else {
|
|
4217
|
+
suite(formatTitle(_name, items, idx), handler ? ()=>handler(i) : undefined, options.timeout);
|
|
4218
|
+
}
|
|
4219
|
+
} else {
|
|
4220
|
+
if (arrayOnlyCases) {
|
|
4221
|
+
suite(formatTitle(_name, items, idx), options, handler ? ()=>handler(...items) : undefined);
|
|
4222
|
+
} else {
|
|
4223
|
+
suite(formatTitle(_name, items, idx), options, handler ? ()=>handler(i) : undefined);
|
|
4224
|
+
}
|
|
4225
|
+
}
|
|
4226
|
+
});
|
|
4227
|
+
this.setContext("each", undefined);
|
|
4228
|
+
};
|
|
4229
|
+
};
|
|
4230
|
+
suiteFn.for = function(cases, ...args) {
|
|
4231
|
+
if (Array.isArray(cases) && args.length) {
|
|
4232
|
+
cases = formatTemplateString(cases, args);
|
|
4233
|
+
}
|
|
4234
|
+
return (name, optionsOrFn, fnOrOptions)=>{
|
|
4235
|
+
const name_ = formatName(name);
|
|
4236
|
+
const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
|
|
4237
|
+
cases.forEach((item, idx)=>{
|
|
4238
|
+
suite(formatTitle(name_, toArray(item), idx), options, handler ? ()=>handler(item) : undefined);
|
|
4239
|
+
});
|
|
4240
|
+
};
|
|
4241
|
+
};
|
|
4242
|
+
suiteFn.skipIf = (condition)=>condition ? suite.skip : suite;
|
|
4243
|
+
suiteFn.runIf = (condition)=>condition ? suite : suite.skip;
|
|
4244
|
+
return createChainable([
|
|
4245
|
+
"concurrent",
|
|
4246
|
+
"sequential",
|
|
4247
|
+
"shuffle",
|
|
4248
|
+
"skip",
|
|
4249
|
+
"only",
|
|
4250
|
+
"todo"
|
|
4251
|
+
], suiteFn);
|
|
4252
|
+
}
|
|
4253
|
+
function createTaskCollector(fn, context) {
|
|
4254
|
+
const taskFn = fn;
|
|
4255
|
+
taskFn.each = function(cases, ...args) {
|
|
4256
|
+
const test = this.withContext();
|
|
4257
|
+
this.setContext("each", true);
|
|
4258
|
+
if (Array.isArray(cases) && args.length) {
|
|
4259
|
+
cases = formatTemplateString(cases, args);
|
|
4260
|
+
}
|
|
4261
|
+
return (name, optionsOrFn, fnOrOptions)=>{
|
|
4262
|
+
const _name = formatName(name);
|
|
4263
|
+
const arrayOnlyCases = cases.every(Array.isArray);
|
|
4264
|
+
const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
|
|
4265
|
+
const fnFirst = typeof optionsOrFn === "function";
|
|
4266
|
+
cases.forEach((i, idx)=>{
|
|
4267
|
+
const items = Array.isArray(i) ? i : [
|
|
4268
|
+
i
|
|
4269
|
+
];
|
|
4270
|
+
if (fnFirst) {
|
|
4271
|
+
if (arrayOnlyCases) {
|
|
4272
|
+
test(formatTitle(_name, items, idx), handler ? ()=>handler(...items) : undefined, options.timeout);
|
|
4273
|
+
} else {
|
|
4274
|
+
test(formatTitle(_name, items, idx), handler ? ()=>handler(i) : undefined, options.timeout);
|
|
4275
|
+
}
|
|
4276
|
+
} else {
|
|
4277
|
+
if (arrayOnlyCases) {
|
|
4278
|
+
test(formatTitle(_name, items, idx), options, handler ? ()=>handler(...items) : undefined);
|
|
4279
|
+
} else {
|
|
4280
|
+
test(formatTitle(_name, items, idx), options, handler ? ()=>handler(i) : undefined);
|
|
4281
|
+
}
|
|
4282
|
+
}
|
|
4283
|
+
});
|
|
4284
|
+
this.setContext("each", undefined);
|
|
4285
|
+
};
|
|
4286
|
+
};
|
|
4287
|
+
taskFn.for = function(cases, ...args) {
|
|
4288
|
+
const test = this.withContext();
|
|
4289
|
+
if (Array.isArray(cases) && args.length) {
|
|
4290
|
+
cases = formatTemplateString(cases, args);
|
|
4291
|
+
}
|
|
4292
|
+
return (name, optionsOrFn, fnOrOptions)=>{
|
|
4293
|
+
const _name = formatName(name);
|
|
4294
|
+
const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
|
|
4295
|
+
cases.forEach((item, idx)=>{
|
|
4296
|
+
// monkey-patch handler to allow parsing fixture
|
|
4297
|
+
const handlerWrapper = handler ? (ctx)=>handler(item, ctx) : undefined;
|
|
4298
|
+
if (handlerWrapper) {
|
|
4299
|
+
handlerWrapper.__VITEST_FIXTURE_INDEX__ = 1;
|
|
4300
|
+
handlerWrapper.toString = ()=>handler.toString();
|
|
4301
|
+
}
|
|
4302
|
+
test(formatTitle(_name, toArray(item), idx), options, handlerWrapper);
|
|
4303
|
+
});
|
|
4304
|
+
};
|
|
4305
|
+
};
|
|
4306
|
+
taskFn.skipIf = function(condition) {
|
|
4307
|
+
return condition ? this.skip : this;
|
|
4308
|
+
};
|
|
4309
|
+
taskFn.runIf = function(condition) {
|
|
4310
|
+
return condition ? this : this.skip;
|
|
4311
|
+
};
|
|
4312
|
+
taskFn.scoped = function(fixtures) {
|
|
4313
|
+
const collector = getCurrentSuite();
|
|
4314
|
+
collector.scoped(fixtures);
|
|
4315
|
+
};
|
|
4316
|
+
taskFn.extend = function(fixtures) {
|
|
4317
|
+
const _context = mergeContextFixtures(fixtures, context || {}, runner);
|
|
4318
|
+
const originalWrapper = fn;
|
|
4319
|
+
return createTest(function(name, optionsOrFn, optionsOrTest) {
|
|
4320
|
+
const collector = getCurrentSuite();
|
|
4321
|
+
const scopedFixtures = collector.fixtures();
|
|
4322
|
+
const context = {
|
|
4323
|
+
...this
|
|
4324
|
+
};
|
|
4325
|
+
if (scopedFixtures) {
|
|
4326
|
+
context.fixtures = mergeScopedFixtures(context.fixtures || [], scopedFixtures);
|
|
4327
|
+
}
|
|
4328
|
+
originalWrapper.call(context, formatName(name), optionsOrFn, optionsOrTest);
|
|
4329
|
+
}, _context);
|
|
4330
|
+
};
|
|
4331
|
+
taskFn.beforeEach = beforeEach;
|
|
4332
|
+
taskFn.afterEach = afterEach;
|
|
4333
|
+
taskFn.beforeAll = beforeAll;
|
|
4334
|
+
taskFn.afterAll = afterAll;
|
|
4335
|
+
const _test = createChainable([
|
|
4336
|
+
"concurrent",
|
|
4337
|
+
"sequential",
|
|
4338
|
+
"skip",
|
|
4339
|
+
"only",
|
|
4340
|
+
"todo",
|
|
4341
|
+
"fails"
|
|
4342
|
+
], taskFn);
|
|
4343
|
+
if (context) {
|
|
4344
|
+
_test.mergeContext(context);
|
|
4345
|
+
}
|
|
4346
|
+
return _test;
|
|
4347
|
+
}
|
|
4348
|
+
function createTest(fn, context) {
|
|
4349
|
+
return createTaskCollector(fn, context);
|
|
4350
|
+
}
|
|
4351
|
+
function formatName(name) {
|
|
4352
|
+
return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
|
|
4353
|
+
}
|
|
4354
|
+
function formatTitle(template, items, idx) {
|
|
4355
|
+
if (template.includes("%#") || template.includes("%$")) {
|
|
4356
|
+
// '%#' match index of the test case
|
|
4357
|
+
template = template.replace(/%%/g, "__vitest_escaped_%__").replace(/%#/g, `${idx}`).replace(/%\$/g, `${idx + 1}`).replace(/__vitest_escaped_%__/g, "%%");
|
|
4358
|
+
}
|
|
4359
|
+
const count = template.split("%").length - 1;
|
|
4360
|
+
if (template.includes("%f")) {
|
|
4361
|
+
const placeholders = template.match(/%f/g) || [];
|
|
4362
|
+
placeholders.forEach((_, i)=>{
|
|
4363
|
+
if (isNegativeNaN(items[i]) || Object.is(items[i], -0)) {
|
|
4364
|
+
// Replace the i-th occurrence of '%f' with '-%f'
|
|
4365
|
+
let occurrence = 0;
|
|
4366
|
+
template = template.replace(/%f/g, (match)=>{
|
|
4367
|
+
occurrence++;
|
|
4368
|
+
return occurrence === i + 1 ? "-%f" : match;
|
|
4369
|
+
});
|
|
4370
|
+
}
|
|
4371
|
+
});
|
|
4372
|
+
}
|
|
4373
|
+
const isObjectItem = isObject(items[0]);
|
|
4374
|
+
function formatAttribute(s) {
|
|
4375
|
+
return s.replace(/\$([$\w.]+)/g, (_, key)=>{
|
|
4376
|
+
const isArrayKey = /^\d+$/.test(key);
|
|
4377
|
+
if (!isObjectItem && !isArrayKey) {
|
|
4378
|
+
return `$${key}`;
|
|
4379
|
+
}
|
|
4380
|
+
const arrayElement = isArrayKey ? objectAttr(items, key) : undefined;
|
|
4381
|
+
const value = isObjectItem ? objectAttr(items[0], key, arrayElement) : arrayElement;
|
|
4382
|
+
return objDisplay(value, {
|
|
4383
|
+
truncate: void 0
|
|
4384
|
+
});
|
|
4385
|
+
});
|
|
4386
|
+
}
|
|
4387
|
+
let output = "";
|
|
4388
|
+
let i = 0;
|
|
4389
|
+
handleRegexMatch(template, formatRegExp, // format "%"
|
|
4390
|
+
(match)=>{
|
|
4391
|
+
if (i < count) {
|
|
4392
|
+
output += format(match[0], items[i++]);
|
|
4393
|
+
} else {
|
|
4394
|
+
output += match[0];
|
|
4395
|
+
}
|
|
4396
|
+
}, // format "$"
|
|
4397
|
+
(nonMatch)=>{
|
|
4398
|
+
output += formatAttribute(nonMatch);
|
|
4399
|
+
});
|
|
4400
|
+
return output;
|
|
4401
|
+
}
|
|
4402
|
+
// based on https://github.com/unocss/unocss/blob/2e74b31625bbe3b9c8351570749aa2d3f799d919/packages/autocomplete/src/parse.ts#L11
|
|
4403
|
+
function handleRegexMatch(input, regex, onMatch, onNonMatch) {
|
|
4404
|
+
let lastIndex = 0;
|
|
4405
|
+
for (const m of input.matchAll(regex)){
|
|
4406
|
+
if (lastIndex < m.index) {
|
|
4407
|
+
onNonMatch(input.slice(lastIndex, m.index));
|
|
4408
|
+
}
|
|
4409
|
+
onMatch(m);
|
|
4410
|
+
lastIndex = m.index + m[0].length;
|
|
4411
|
+
}
|
|
4412
|
+
if (lastIndex < input.length) {
|
|
4413
|
+
onNonMatch(input.slice(lastIndex));
|
|
4414
|
+
}
|
|
4415
|
+
}
|
|
4416
|
+
function formatTemplateString(cases, args) {
|
|
4417
|
+
const header = cases.join("").trim().replace(/ /g, "").split("\n").map((i)=>i.split("|"))[0];
|
|
4418
|
+
const res = [];
|
|
4419
|
+
for(let i = 0; i < Math.floor(args.length / header.length); i++){
|
|
4420
|
+
const oneCase = {};
|
|
4421
|
+
for(let j = 0; j < header.length; j++){
|
|
4422
|
+
oneCase[header[j]] = args[i * header.length + j];
|
|
4423
|
+
}
|
|
4424
|
+
res.push(oneCase);
|
|
4425
|
+
}
|
|
4426
|
+
return res;
|
|
4427
|
+
}
|
|
4428
|
+
const now$2 = Date.now;
|
|
4429
|
+
const collectorContext = {
|
|
4430
|
+
currentSuite: null
|
|
4431
|
+
};
|
|
4432
|
+
function collectTask(task) {
|
|
4433
|
+
var _collectorContext$cur;
|
|
4434
|
+
(_collectorContext$cur = collectorContext.currentSuite) === null || _collectorContext$cur === void 0 ? void 0 : _collectorContext$cur.tasks.push(task);
|
|
4435
|
+
}
|
|
4436
|
+
async function runWithSuite(suite, fn) {
|
|
4437
|
+
const prev = collectorContext.currentSuite;
|
|
4438
|
+
collectorContext.currentSuite = suite;
|
|
4439
|
+
await fn();
|
|
4440
|
+
collectorContext.currentSuite = prev;
|
|
4441
|
+
}
|
|
4442
|
+
function withTimeout(fn, timeout, isHook = false, stackTraceError, onTimeout) {
|
|
4443
|
+
if (timeout <= 0 || timeout === Number.POSITIVE_INFINITY) {
|
|
4444
|
+
return fn;
|
|
4445
|
+
}
|
|
4446
|
+
const { setTimeout, clearTimeout } = getSafeTimers();
|
|
4447
|
+
// this function name is used to filter error in test/cli/test/fails.test.ts
|
|
4448
|
+
return function runWithTimeout(...args) {
|
|
4449
|
+
const startTime = now$2();
|
|
4450
|
+
const runner = getRunner();
|
|
4451
|
+
runner._currentTaskStartTime = startTime;
|
|
4452
|
+
runner._currentTaskTimeout = timeout;
|
|
4453
|
+
return new Promise((resolve_, reject_)=>{
|
|
4454
|
+
var _timer$unref;
|
|
4455
|
+
const timer = setTimeout(()=>{
|
|
4456
|
+
clearTimeout(timer);
|
|
4457
|
+
rejectTimeoutError();
|
|
4458
|
+
}, timeout);
|
|
4459
|
+
// `unref` might not exist in browser
|
|
4460
|
+
(_timer$unref = timer.unref) === null || _timer$unref === void 0 ? void 0 : _timer$unref.call(timer);
|
|
4461
|
+
function rejectTimeoutError() {
|
|
4462
|
+
const error = makeTimeoutError(isHook, timeout, stackTraceError);
|
|
4463
|
+
onTimeout === null || onTimeout === void 0 ? void 0 : onTimeout(args, error);
|
|
4464
|
+
reject_(error);
|
|
4465
|
+
}
|
|
4466
|
+
function resolve(result) {
|
|
4467
|
+
runner._currentTaskStartTime = undefined;
|
|
4468
|
+
runner._currentTaskTimeout = undefined;
|
|
4469
|
+
clearTimeout(timer);
|
|
4470
|
+
// if test/hook took too long in microtask, setTimeout won't be triggered,
|
|
4471
|
+
// but we still need to fail the test, see
|
|
4472
|
+
// https://github.com/vitest-dev/vitest/issues/2920
|
|
4473
|
+
if (now$2() - startTime >= timeout) {
|
|
4474
|
+
rejectTimeoutError();
|
|
4475
|
+
return;
|
|
4476
|
+
}
|
|
4477
|
+
resolve_(result);
|
|
4478
|
+
}
|
|
4479
|
+
function reject(error) {
|
|
4480
|
+
runner._currentTaskStartTime = undefined;
|
|
4481
|
+
runner._currentTaskTimeout = undefined;
|
|
4482
|
+
clearTimeout(timer);
|
|
4483
|
+
reject_(error);
|
|
4484
|
+
}
|
|
4485
|
+
// sync test/hook will be caught by try/catch
|
|
4486
|
+
try {
|
|
4487
|
+
const result = fn(...args);
|
|
4488
|
+
// the result is a thenable, we don't wrap this in Promise.resolve
|
|
4489
|
+
// to avoid creating new promises
|
|
4490
|
+
if (typeof result === "object" && result != null && typeof result.then === "function") {
|
|
4491
|
+
result.then(resolve, reject);
|
|
4492
|
+
} else {
|
|
4493
|
+
resolve(result);
|
|
4494
|
+
}
|
|
4495
|
+
} // user sync test/hook throws an error
|
|
4496
|
+
catch (error) {
|
|
4497
|
+
reject(error);
|
|
4498
|
+
}
|
|
4499
|
+
});
|
|
4500
|
+
};
|
|
4501
|
+
}
|
|
4502
|
+
const abortControllers = new WeakMap();
|
|
4503
|
+
function abortIfTimeout([context], error) {
|
|
4504
|
+
if (context) {
|
|
4505
|
+
abortContextSignal(context, error);
|
|
4506
|
+
}
|
|
4507
|
+
}
|
|
4508
|
+
function abortContextSignal(context, error) {
|
|
4509
|
+
const abortController = abortControllers.get(context);
|
|
4510
|
+
abortController === null || abortController === void 0 ? void 0 : abortController.abort(error);
|
|
4511
|
+
}
|
|
4512
|
+
function createTestContext(test, runner) {
|
|
4513
|
+
var _runner$extendTaskCon;
|
|
4514
|
+
const context = function() {
|
|
4515
|
+
throw new Error("done() callback is deprecated, use promise instead");
|
|
4516
|
+
};
|
|
4517
|
+
let abortController = abortControllers.get(context);
|
|
4518
|
+
if (!abortController) {
|
|
4519
|
+
abortController = new AbortController();
|
|
4520
|
+
abortControllers.set(context, abortController);
|
|
4521
|
+
}
|
|
4522
|
+
context.signal = abortController.signal;
|
|
4523
|
+
context.task = test;
|
|
4524
|
+
context.skip = (condition, note)=>{
|
|
4525
|
+
if (condition === false) {
|
|
4526
|
+
// do nothing
|
|
4527
|
+
return undefined;
|
|
4528
|
+
}
|
|
4529
|
+
test.result ?? (test.result = {
|
|
4530
|
+
state: "skip"
|
|
4531
|
+
});
|
|
4532
|
+
test.result.pending = true;
|
|
4533
|
+
throw new PendingError("test is skipped; abort execution", test, typeof condition === "string" ? condition : note);
|
|
4534
|
+
};
|
|
4535
|
+
context.annotate = (message, type, attachment)=>{
|
|
4536
|
+
if (test.result && test.result.state !== "run") {
|
|
4537
|
+
throw new Error(`Cannot annotate tests outside of the test run. The test "${test.name}" finished running with the "${test.result.state}" state already.`);
|
|
4538
|
+
}
|
|
4539
|
+
const annotation = {
|
|
4540
|
+
message,
|
|
4541
|
+
type: typeof type === "object" || type === undefined ? "notice" : type
|
|
4542
|
+
};
|
|
4543
|
+
const annotationAttachment = typeof type === "object" ? type : attachment;
|
|
4544
|
+
if (annotationAttachment) {
|
|
4545
|
+
annotation.attachment = annotationAttachment;
|
|
4546
|
+
manageArtifactAttachment(annotation.attachment);
|
|
4547
|
+
}
|
|
4548
|
+
return recordAsyncOperation(test, recordArtifact(test, {
|
|
4549
|
+
type: "internal:annotation",
|
|
4550
|
+
annotation
|
|
4551
|
+
}).then(async ({ annotation })=>{
|
|
4552
|
+
if (!runner.onTestAnnotate) {
|
|
4553
|
+
throw new Error(`Test runner doesn't support test annotations.`);
|
|
4554
|
+
}
|
|
4555
|
+
await finishSendTasksUpdate(runner);
|
|
4556
|
+
const resolvedAnnotation = await runner.onTestAnnotate(test, annotation);
|
|
4557
|
+
test.annotations.push(resolvedAnnotation);
|
|
4558
|
+
return resolvedAnnotation;
|
|
4559
|
+
}));
|
|
4560
|
+
};
|
|
4561
|
+
context.onTestFailed = (handler, timeout)=>{
|
|
4562
|
+
test.onFailed || (test.onFailed = []);
|
|
4563
|
+
test.onFailed.push(withTimeout(handler, timeout ?? runner.config.hookTimeout, true, new Error("STACK_TRACE_ERROR"), (_, error)=>abortController.abort(error)));
|
|
4564
|
+
};
|
|
4565
|
+
context.onTestFinished = (handler, timeout)=>{
|
|
4566
|
+
test.onFinished || (test.onFinished = []);
|
|
4567
|
+
test.onFinished.push(withTimeout(handler, timeout ?? runner.config.hookTimeout, true, new Error("STACK_TRACE_ERROR"), (_, error)=>abortController.abort(error)));
|
|
4568
|
+
};
|
|
4569
|
+
return ((_runner$extendTaskCon = runner.extendTaskContext) === null || _runner$extendTaskCon === void 0 ? void 0 : _runner$extendTaskCon.call(runner, context)) || context;
|
|
4570
|
+
}
|
|
4571
|
+
function makeTimeoutError(isHook, timeout, stackTraceError) {
|
|
4572
|
+
const message = `${isHook ? "Hook" : "Test"} timed out in ${timeout}ms.\nIf this is a long-running ${isHook ? "hook" : "test"}, pass a timeout value as the last argument or configure it globally with "${isHook ? "hookTimeout" : "testTimeout"}".`;
|
|
4573
|
+
const error = new Error(message);
|
|
4574
|
+
if (stackTraceError === null || stackTraceError === void 0 ? void 0 : stackTraceError.stack) {
|
|
4575
|
+
error.stack = stackTraceError.stack.replace(error.message, stackTraceError.message);
|
|
4576
|
+
}
|
|
4577
|
+
return error;
|
|
4578
|
+
}
|
|
4579
|
+
const fileContexts = new WeakMap();
|
|
4580
|
+
function getFileContext(file) {
|
|
4581
|
+
const context = fileContexts.get(file);
|
|
4582
|
+
if (!context) {
|
|
4583
|
+
throw new Error(`Cannot find file context for ${file.name}`);
|
|
4584
|
+
}
|
|
4585
|
+
return context;
|
|
4586
|
+
}
|
|
4587
|
+
globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
4588
|
+
globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
4589
|
+
getSafeTimers();
|
|
4590
|
+
const packs = new Map();
|
|
4591
|
+
const eventsPacks = [];
|
|
4592
|
+
const pendingTasksUpdates = [];
|
|
4593
|
+
function sendTasksUpdate(runner) {
|
|
4594
|
+
if (packs.size) {
|
|
4595
|
+
var _runner$onTaskUpdate;
|
|
4596
|
+
const taskPacks = Array.from(packs).map(([id, task])=>{
|
|
4597
|
+
return [
|
|
4598
|
+
id,
|
|
4599
|
+
task[0],
|
|
4600
|
+
task[1]
|
|
4601
|
+
];
|
|
4602
|
+
});
|
|
4603
|
+
const p = (_runner$onTaskUpdate = runner.onTaskUpdate) === null || _runner$onTaskUpdate === void 0 ? void 0 : _runner$onTaskUpdate.call(runner, taskPacks, eventsPacks);
|
|
4604
|
+
if (p) {
|
|
4605
|
+
pendingTasksUpdates.push(p);
|
|
4606
|
+
// remove successful promise to not grow array indefnitely,
|
|
4607
|
+
// but keep rejections so finishSendTasksUpdate can handle them
|
|
4608
|
+
p.then(()=>pendingTasksUpdates.splice(pendingTasksUpdates.indexOf(p), 1), ()=>{});
|
|
4609
|
+
}
|
|
4610
|
+
eventsPacks.length = 0;
|
|
4611
|
+
packs.clear();
|
|
4612
|
+
}
|
|
4613
|
+
}
|
|
4614
|
+
async function finishSendTasksUpdate(runner) {
|
|
4615
|
+
sendTasksUpdate(runner);
|
|
4616
|
+
await Promise.all(pendingTasksUpdates);
|
|
4617
|
+
}
|
|
4618
|
+
/**
|
|
4619
|
+
* @experimental
|
|
4620
|
+
* @advanced
|
|
4621
|
+
*
|
|
4622
|
+
* Records a custom test artifact during test execution.
|
|
4623
|
+
*
|
|
4624
|
+
* This function allows you to attach structured data, files, or metadata to a test.
|
|
4625
|
+
*
|
|
4626
|
+
* Vitest automatically injects the source location where the artifact was created and manages any attachments you include.
|
|
4627
|
+
*
|
|
4628
|
+
* @param task - The test task context, typically accessed via `this.task` in custom matchers or `context.task` in tests
|
|
4629
|
+
* @param artifact - The artifact to record. Must extend {@linkcode TestArtifactBase}
|
|
4630
|
+
*
|
|
4631
|
+
* @returns A promise that resolves to the recorded artifact with location injected
|
|
4632
|
+
*
|
|
4633
|
+
* @throws {Error} If called after the test has finished running
|
|
4634
|
+
* @throws {Error} If the test runner doesn't support artifacts
|
|
4635
|
+
*
|
|
4636
|
+
* @example
|
|
4637
|
+
* ```ts
|
|
4638
|
+
* // In a custom assertion
|
|
4639
|
+
* async function toHaveValidSchema(this: MatcherState, actual: unknown) {
|
|
4640
|
+
* const validation = validateSchema(actual)
|
|
4641
|
+
*
|
|
4642
|
+
* await recordArtifact(this.task, {
|
|
4643
|
+
* type: 'my-plugin:schema-validation',
|
|
4644
|
+
* passed: validation.valid,
|
|
4645
|
+
* errors: validation.errors,
|
|
4646
|
+
* })
|
|
4647
|
+
*
|
|
4648
|
+
* return { pass: validation.valid, message: () => '...' }
|
|
4649
|
+
* }
|
|
4650
|
+
* ```
|
|
4651
|
+
*/ async function recordArtifact(task, artifact) {
|
|
4652
|
+
const runner = getRunner();
|
|
4653
|
+
if (task.result && task.result.state !== "run") {
|
|
4654
|
+
throw new Error(`Cannot record a test artifact outside of the test run. The test "${task.name}" finished running with the "${task.result.state}" state already.`);
|
|
4655
|
+
}
|
|
4656
|
+
const stack = findTestFileStackTrace(task.file.filepath, new Error("STACK_TRACE").stack);
|
|
4657
|
+
if (stack) {
|
|
4658
|
+
artifact.location = {
|
|
4659
|
+
file: stack.file,
|
|
4660
|
+
line: stack.line,
|
|
4661
|
+
column: stack.column
|
|
4662
|
+
};
|
|
4663
|
+
if (artifact.type === "internal:annotation") {
|
|
4664
|
+
artifact.annotation.location = artifact.location;
|
|
4665
|
+
}
|
|
4666
|
+
}
|
|
4667
|
+
if (Array.isArray(artifact.attachments)) {
|
|
4668
|
+
for (const attachment of artifact.attachments){
|
|
4669
|
+
manageArtifactAttachment(attachment);
|
|
4670
|
+
}
|
|
4671
|
+
}
|
|
4672
|
+
// annotations won't resolve as artifacts for backwards compatibility until next major
|
|
4673
|
+
if (artifact.type === "internal:annotation") {
|
|
4674
|
+
return artifact;
|
|
4675
|
+
}
|
|
4676
|
+
if (!runner.onTestArtifactRecord) {
|
|
4677
|
+
throw new Error(`Test runner doesn't support test artifacts.`);
|
|
4678
|
+
}
|
|
4679
|
+
await finishSendTasksUpdate(runner);
|
|
4680
|
+
const resolvedArtifact = await runner.onTestArtifactRecord(task, artifact);
|
|
4681
|
+
task.artifacts.push(resolvedArtifact);
|
|
4682
|
+
return resolvedArtifact;
|
|
4683
|
+
}
|
|
4684
|
+
const table = [];
|
|
4685
|
+
for(let i = 65; i < 91; i++){
|
|
4686
|
+
table.push(String.fromCharCode(i));
|
|
4687
|
+
}
|
|
4688
|
+
for(let i = 97; i < 123; i++){
|
|
4689
|
+
table.push(String.fromCharCode(i));
|
|
4690
|
+
}
|
|
4691
|
+
for(let i = 0; i < 10; i++){
|
|
4692
|
+
table.push(i.toString(10));
|
|
4693
|
+
}
|
|
4694
|
+
table.push("+", "/");
|
|
4695
|
+
function encodeUint8Array(bytes) {
|
|
4696
|
+
let base64 = "";
|
|
4697
|
+
const len = bytes.byteLength;
|
|
4698
|
+
for(let i = 0; i < len; i += 3){
|
|
4699
|
+
if (len === i + 1) {
|
|
4700
|
+
const a = (bytes[i] & 252) >> 2;
|
|
4701
|
+
const b = (bytes[i] & 3) << 4;
|
|
4702
|
+
base64 += table[a];
|
|
4703
|
+
base64 += table[b];
|
|
4704
|
+
base64 += "==";
|
|
4705
|
+
} else if (len === i + 2) {
|
|
4706
|
+
const a = (bytes[i] & 252) >> 2;
|
|
4707
|
+
const b = (bytes[i] & 3) << 4 | (bytes[i + 1] & 240) >> 4;
|
|
4708
|
+
const c = (bytes[i + 1] & 15) << 2;
|
|
4709
|
+
base64 += table[a];
|
|
4710
|
+
base64 += table[b];
|
|
4711
|
+
base64 += table[c];
|
|
4712
|
+
base64 += "=";
|
|
4713
|
+
} else {
|
|
4714
|
+
const a = (bytes[i] & 252) >> 2;
|
|
4715
|
+
const b = (bytes[i] & 3) << 4 | (bytes[i + 1] & 240) >> 4;
|
|
4716
|
+
const c = (bytes[i + 1] & 15) << 2 | (bytes[i + 2] & 192) >> 6;
|
|
4717
|
+
const d = bytes[i + 2] & 63;
|
|
4718
|
+
base64 += table[a];
|
|
4719
|
+
base64 += table[b];
|
|
4720
|
+
base64 += table[c];
|
|
4721
|
+
base64 += table[d];
|
|
4722
|
+
}
|
|
4723
|
+
}
|
|
4724
|
+
return base64;
|
|
4725
|
+
}
|
|
4726
|
+
/**
|
|
4727
|
+
* Records an async operation associated with a test task.
|
|
4728
|
+
*
|
|
4729
|
+
* This function tracks promises that should be awaited before a test completes.
|
|
4730
|
+
* The promise is automatically removed from the test's promise list once it settles.
|
|
4731
|
+
*/ function recordAsyncOperation(test, promise) {
|
|
4732
|
+
// if promise is explicitly awaited, remove it from the list
|
|
4733
|
+
promise = promise.finally(()=>{
|
|
4734
|
+
if (!test.promises) {
|
|
4735
|
+
return;
|
|
4736
|
+
}
|
|
4737
|
+
const index = test.promises.indexOf(promise);
|
|
4738
|
+
if (index !== -1) {
|
|
4739
|
+
test.promises.splice(index, 1);
|
|
4740
|
+
}
|
|
4741
|
+
});
|
|
4742
|
+
// record promise
|
|
4743
|
+
if (!test.promises) {
|
|
4744
|
+
test.promises = [];
|
|
4745
|
+
}
|
|
4746
|
+
test.promises.push(promise);
|
|
4747
|
+
return promise;
|
|
4748
|
+
}
|
|
4749
|
+
/**
|
|
4750
|
+
* Validates and prepares a test attachment for serialization.
|
|
4751
|
+
*
|
|
4752
|
+
* This function ensures attachments have either `body` or `path` set (but not both), and converts `Uint8Array` bodies to base64-encoded strings for easier serialization.
|
|
4753
|
+
*
|
|
4754
|
+
* @param attachment - The attachment to validate and prepare
|
|
4755
|
+
*
|
|
4756
|
+
* @throws {TypeError} If neither `body` nor `path` is provided
|
|
4757
|
+
* @throws {TypeError} If both `body` and `path` are provided
|
|
4758
|
+
*/ function manageArtifactAttachment(attachment) {
|
|
4759
|
+
if (attachment.body == null && !attachment.path) {
|
|
4760
|
+
throw new TypeError(`Test attachment requires "body" or "path" to be set. Both are missing.`);
|
|
4761
|
+
}
|
|
4762
|
+
if (attachment.body && attachment.path) {
|
|
4763
|
+
throw new TypeError(`Test attachment requires only one of "body" or "path" to be set. Both are specified.`);
|
|
4764
|
+
}
|
|
4765
|
+
// convert to a string so it's easier to serialise
|
|
4766
|
+
if (attachment.body instanceof Uint8Array) {
|
|
4767
|
+
attachment.body = encodeUint8Array(attachment.body);
|
|
4768
|
+
}
|
|
4769
|
+
}
|
|
4770
|
+
|
|
4771
|
+
function createSpec(spec) {
|
|
4772
|
+
const proto = Object.getPrototypeOf(spec);
|
|
4773
|
+
let describeFn;
|
|
4774
|
+
const specName = proto.constructor.name;
|
|
4775
|
+
if (specName.startsWith('fff')) {
|
|
4776
|
+
describeFn = describe.only;
|
|
4777
|
+
} else if (specName.startsWith('xxx')) {
|
|
4778
|
+
describeFn = describe.skip;
|
|
4779
|
+
} else {
|
|
4780
|
+
describeFn = describe;
|
|
4781
|
+
}
|
|
4782
|
+
describeFn(specName, ()=>createTestCases(spec));
|
|
4783
|
+
}
|
|
4784
|
+
function createTestCases(spec) {
|
|
4785
|
+
let proto = Object.getPrototypeOf(spec);
|
|
4786
|
+
const processedMethodsMap = {};
|
|
4787
|
+
while(proto.constructor !== Object){
|
|
4788
|
+
for (const key of Object.getOwnPropertyNames(proto)){
|
|
4789
|
+
const isProcessed = processedMethodsMap[key];
|
|
4790
|
+
processedMethodsMap[key] = true;
|
|
4791
|
+
const method = spec[key];
|
|
4792
|
+
if (isProcessed || key === 'constructor' || typeof method !== 'function') {
|
|
4793
|
+
continue;
|
|
4794
|
+
}
|
|
4795
|
+
const callback = method.bind(spec);
|
|
4796
|
+
const hookFn = hooks[key];
|
|
4797
|
+
if (hookFn) {
|
|
4798
|
+
hookFn(callback);
|
|
4799
|
+
} else if (key.startsWith('should')) {
|
|
4800
|
+
it(key, callback);
|
|
4801
|
+
} else if (key.startsWith('fffShould')) {
|
|
4802
|
+
it.only(key, callback);
|
|
4803
|
+
} else if (key.startsWith('xxxShould')) {
|
|
4804
|
+
it.skip(key, callback);
|
|
4805
|
+
}
|
|
4806
|
+
}
|
|
4807
|
+
proto = Object.getPrototypeOf(proto);
|
|
4808
|
+
}
|
|
4809
|
+
}
|
|
4810
|
+
const hooks = {
|
|
4811
|
+
beforeAll,
|
|
4812
|
+
beforeEach,
|
|
4813
|
+
afterEach,
|
|
4814
|
+
afterAll
|
|
4815
|
+
};
|
|
4816
|
+
|
|
4817
|
+
export { BaseEntity, _Company as Company, _InventoryAdjustment as InventoryAdjustment, _Item as Item, _ItemAdjustment as ItemAdjustment, _ItemTag as ItemTag, _LedgerAccount as LedgerAccount, _MeasureUnit as MeasureUnit, _MeasureUnitCategory as MeasureUnitCategory, _Profile as Profile, _Storehouse as Storehouse, _Tag as Tag, _Tax as Tax, _TaxCategory as TaxCategory, _User as User, _UserWithNonUpdatableId as UserWithNonUpdatableId, clearTables, createSpec, createTables, dropTables };
|
|
4818
|
+
//# sourceMappingURL=uql-browser.min.js.map
|