Skip to main content

Crate use_js

Crate use_js 

Source
Expand description

§use-js

Feature-gated facade crate for the focused RustUse JavaScript ecosystem primitives.

§Experimental

use-js is experimental while the workspace remains below 0.3.0. Expect small API adjustments during the first release wave.

§Example

use use_js::{AstroRenderingMode, EcmaScriptTarget, JsIdentifier, NextJsRouteSegment, PackageName, ReactComponentName};

let target: EcmaScriptTarget = "es2024".parse()?;
let identifier = JsIdentifier::new("createApp")?;
let package = PackageName::new("@rustuse/example")?;
let component = ReactComponentName::new("AppShell")?;
let route_segment = NextJsRouteSegment::new("blog")?;

assert_eq!(target.to_string(), "ES2024");
assert_eq!(identifier.as_str(), "createApp");
assert!(package.is_scoped());
assert_eq!(component.as_str(), "AppShell");
assert_eq!(AstroRenderingMode::Hybrid.as_str(), "hybrid");
assert_eq!(route_segment.as_str(), "blog");

§Scope

  • Thin re-exports over the focused crates in this workspace.
  • Feature flags that map directly to child crates.
  • One dependency when consumer ergonomics matter more than the narrowest possible dependency graph.

§Non-goals

  • JavaScript or TypeScript runtime behavior.
  • Full source parsing, bundling, transpilation, scaffolding, or package-manager execution.
  • A second abstraction layer over the focused crates.

§License

Licensed under either Apache-2.0 or MIT.

Modules§

angular
astro
bun
deno
ecmascript
export
identifier
import
jquery
keyword
lit
module
next
node_js
npm
nuxt
package_json
pnpm
preact
prelude
Curated facade prelude for common JavaScript ecosystem primitives.
qwik
react
remix
solid
storybook
svelte
ts
tsconfig
value
vite
vue
yarn

Structs§

AngularDirectiveName
Validated Angular directive class name metadata.
AngularModuleName
Validated Angular module name metadata.
AngularSelector
Validated Angular selector metadata.
AstroContentCollectionName
Validated Astro content collection name metadata.
AstroIntegrationName
Validated Astro integration name metadata.
BunVersion
Bun version metadata.
CompilerOptions
Partial compiler options metadata.
DenoVersion
Deno version metadata.
EcmaScriptYear
Calendar year for annual ECMAScript editions.
JqueryEffectName
Validated jQuery effect name metadata.
JqueryEventName
Validated jQuery event name metadata.
JqueryPluginName
Validated jQuery plugin name metadata.
JquerySelector
Validated non-empty jQuery selector text.
JsExportSpecifier
Exported binding metadata.
JsExportStatementParts
Lightweight export statement metadata.
JsIdentifier
Validated ASCII-safe JavaScript identifier.
JsImportSpecifier
Imported binding metadata.
JsImportStatementParts
Lightweight import statement metadata.
JsModuleFormat
Simple module format metadata.
JsModuleSpecifier
Validated JavaScript module specifier.
LitDecoratorName
Validated Lit decorator name metadata.
LitElementName
Validated Lit custom element name metadata.
LitPropertyName
Validated Lit property name metadata.
NextJsDynamicSegment
Validated Next.js dynamic segment metadata.
NextJsInterceptingRoutePattern
Validated Next.js intercepting route pattern metadata.
NextJsParallelRouteName
Validated Next.js parallel route name metadata.
NextJsRouteSegment
Validated Next.js route segment metadata.
NodeMajorVersion
Node.js major version metadata.
NodeRuntime
Node.js runtime metadata.
NodeVersion
Node.js version metadata.
NpmPackageSpec
NpmRegistryUrl
npm registry URL metadata.
NpmScriptCommand
PackageJson
Partial practical package.json metadata.
PackageName
Validated package name metadata.
PackageScript
PackageScriptName
PackageVersion
PnpmFilter
PnpmWorkspace
PreactComponentName
Validated Preact component name metadata.
PreactHookName
Validated Preact hook name metadata.
QwikComponentName
Validated Qwik component name metadata.
ReactComponentName
Validated React component name metadata.
ReactHookName
Validated React hook name metadata.
RemixResourceRouteName
Validated Remix resource route name metadata.
RemixRouteFileName
Validated Remix route file name metadata.
RemixRoutePath
Validated Remix route path metadata.
SolidComponentName
Validated SolidJS component name metadata.
SolidSignalName
Validated SolidJS signal name metadata.
StorybookArgName
Validated Storybook arg name metadata.
StorybookComponentTitle
Validated Storybook component title metadata.
StorybookStoryName
Validated Storybook story name metadata.
SvelteComponentName
Validated Svelte component name metadata.
SvelteDirectiveName
Validated Svelte directive name metadata.
TsConfig
Partial tsconfig.json metadata.
TsConfigExclude
TsConfigExtends
TsConfigInclude
TypeScriptVersion
TypeScript semantic version metadata.
ViteMode
VitePluginName
VueComponentName
Validated Vue component name metadata.
VueDirectiveName
Validated Vue directive name metadata without the leading v-.
YarnWorkspace

Enums§

AngularArtifactKind
Angular artifact-kind labels.
AngularConfigFile
Common Angular config file labels.
AngularFileKind
Angular file-kind labels.
AngularNameError
Error returned when Angular metadata is invalid.
AngularStandaloneMode
Angular standalone mode labels.
AngularVersionFamily
Angular version-family labels.
AstroConfigFile
Common Astro config file labels.
AstroDirectoryKind
Astro directory labels.
AstroFileKind
Astro file-kind labels.
AstroRenderingMode
Astro rendering mode labels.
AstroTextError
Error returned when Astro metadata text is invalid.
AstroVersionFamily
Astro version-family labels.
BunCommand
Common Bun command labels.
BunLockfile
Common Bun lockfile labels.
DenoConfigFile
Common Deno config file labels.
DenoPermission
Deno permission labels.
DependencyKind
package.json dependency section kind.
EcmaScriptEdition
ECMAScript edition numbers for commonly named targets.
EcmaScriptParseError
Error returned while parsing ECMAScript labels.
EcmaScriptTarget
Common ECMAScript language target labels.
JqueryAjaxMethod
Common jQuery AJAX method labels.
JqueryTextError
Error returned when jQuery metadata text is invalid.
JqueryVersionFamily
jQuery version-family labels.
JsExportKind
JavaScript export metadata kind.
JsIdentifierError
Error returned when an ASCII JavaScript identifier is invalid.
JsImportKind
JavaScript import metadata kind.
JsKeyword
Common JavaScript keywords.
JsKeywordParseError
Error returned when parsing JavaScript vocabulary fails.
JsModuleKind
JavaScript module-system kind.
JsModuleKindParseError
Error returned when a module kind is not recognized.
JsModuleSpecifierError
Error returned when a module specifier is invalid.
JsPrimitiveValue
Primitive JavaScript-like values for metadata and validation helpers.
JsReservedWord
JavaScript reserved words, including keywords and common future reserved words.
LitFileKind
Lit file-kind labels.
LitNameError
Error returned when Lit metadata is invalid.
LitTemplateKind
Lit template-kind labels.
NextJsConfigFile
Common Next.js config file labels.
NextJsDirectoryKind
Next.js directory labels.
NextJsFileKind
Next.js file-kind labels.
NextJsMetadataKind
Next.js metadata-kind labels.
NextJsRenderingMode
Next.js rendering mode labels.
NextJsRouteError
Error returned when Next.js route metadata is invalid.
NextJsRouteKind
Next.js route-kind labels.
NextJsRouterKind
Next.js router-kind labels.
NextJsRuntimeKind
Next.js runtime-kind labels.
NextJsVersionFamily
Next.js version-family labels.
NodePackageManagerPreference
Preferred package manager for a Node-oriented project.
NodeVersionParseError
Error returned while parsing a Node.js version.
NpmCommand
Common npm command labels.
NpmCommandParseError
Error returned while parsing npm commands.
NpmTextError
Error returned when npm text metadata is invalid.
NuxtConfigFile
Common Nuxt config file labels.
NuxtDirectoryKind
Common Nuxt directory labels.
NuxtRenderingMode
Nuxt rendering mode labels.
NuxtVersionFamily
Nuxt version-family labels.
PackageJsonTextError
Error returned when package metadata text is invalid.
PackageType
package.json package type metadata.
PnpmCommand
Common pnpm command labels.
PnpmLockfile
Common pnpm lockfile labels.
PnpmTextError
Error returned when pnpm text metadata is invalid.
PreactCompatMode
Preact compatibility mode labels.
PreactFileKind
Preact file-kind labels.
PreactJsxRuntime
Preact JSX runtime labels.
PreactNameError
Error returned when Preact metadata is invalid.
QwikCityRouteKind
Qwik City route-kind labels.
QwikConfigFile
Common Qwik config file labels.
QwikDirectoryKind
Qwik directory labels.
QwikFileKind
Qwik file-kind labels.
QwikNameError
Error returned when Qwik metadata is invalid.
QwikOptimizerMode
Qwik optimizer mode labels.
ReactFileKind
React file-kind metadata.
ReactJsxRuntime
React JSX runtime labels.
ReactNameError
Error returned when React name metadata is invalid.
RemixConfigFile
Common Remix config file labels.
RemixDataFunctionKind
Remix data function labels.
RemixDirectoryKind
Remix directory labels.
RemixFileKind
Remix file-kind labels.
RemixNameError
Error returned when Remix metadata is invalid.
RemixRenderingMode
Remix rendering-mode labels.
RemixRouteKind
Remix route-kind labels.
RemixVersionFamily
Remix version-family labels.
SolidFileKind
SolidJS file-kind labels.
SolidJsxRuntime
SolidJS JSX runtime labels.
SolidNameError
Error returned when SolidJS metadata is invalid.
SolidPrimitiveKind
SolidJS primitive-kind labels.
StorybookAddonKind
Storybook addon labels.
StorybookConfigFile
Common Storybook config file labels.
StorybookControlKind
Storybook control-kind labels.
StorybookFileKind
Storybook file-kind labels.
StorybookFrameworkKind
Storybook framework labels.
StorybookNameError
Error returned when Storybook metadata is invalid.
StorybookParameterKind
Storybook parameter-kind labels.
StorybookStoryKind
Storybook story-kind labels.
StorybookVersionFamily
Storybook version-family labels.
SvelteConfigFile
Common Svelte config file labels.
SvelteFileKind
Svelte file-kind labels.
SvelteKitDirectoryKind
SvelteKit directory labels.
SvelteKitRenderingMode
SvelteKit rendering mode labels.
SvelteNameError
Error returned when Svelte metadata is invalid.
TsConfigTextError
Error returned when tsconfig text metadata is empty.
TsModuleResolution
TypeScript module resolution labels.
TsOptionParseError
Error returned while parsing TypeScript option labels.
TsStrictness
TypeScript strictness metadata.
TsTarget
TypeScript target metadata.
TsTargetParseError
Error returned while parsing TypeScript targets.
TypeScriptVersionParseError
Error returned while parsing a TypeScript version.
ViteConfigFile
Common Vite config file labels.
ViteFrameworkPreset
Vite framework preset labels.
ViteTextError
Error returned when Vite text metadata is empty.
VueApiStyle
Vue API style labels.
VueFileKind
Vue file-kind metadata.
VueNameError
Error returned when Vue name metadata is invalid.
YarnCommand
Common Yarn command labels.
YarnLockfile
Common Yarn lockfile label.
YarnTextError
Error returned when Yarn text metadata is invalid.
YarnVersionFamily
Yarn release-line family.

Constants§

ES5
ES2015
ES2016
ES2017
ES2018
ES2019
ES2020
ES2021
ES2022
ES2023
ES2024
ESNEXT

Functions§

is_ascii_js_identifier_continue
Returns whether character is accepted after the first identifier character.
is_ascii_js_identifier_start
Returns whether character is accepted as an ASCII JavaScript identifier start.
is_js_keyword
Returns whether input is one of the common JavaScript keywords.
is_js_reserved_word
Returns whether input is a keyword or common reserved word.
is_valid_ascii_js_identifier
Returns whether input is an ASCII-safe JavaScript identifier.

Type Aliases§

DependencyMap
Dependency map keyed by package name.