Sha256: f9fde4791d1bdfd149dce2aed2e4a5e6c0b9ef0d797eaa2539243619c9465193

Contents?: true

Size: 1.43 KB

Versions: 20

Compression:

Stored size: 1.43 KB

Contents

import {Application, type ControllerConstructor} from '@hotwired/stimulus'

const application = Application.start()

application.debug = import.meta.env.DEV

declare global {
  interface Window {
    Stimulus: Application
  }
}

window.Stimulus = application

// Force Vite to process component JS
const componentModules = import.meta.glob(['../../components/**/component.ts'], {eager: true})
import.meta.glob(['../../components/**/component.css'], {eager: true})

for (const [path, module] of Object.entries(componentModules)) {
  const dirs = path.split('/')

  // Dropping ../../components and component.ts parts to end up
  // with something like "ariadne-ui-component-name"
  const name = dirs
    .slice(3, dirs.length - 1)
    .join('-')
    .replaceAll('_', '-')
    .toLocaleLowerCase()

  application.register(
    // @tag stimulus-id
    name,
    (module as {default: ControllerConstructor}).default,
  )
}

const controllerModules = import.meta.glob(['~/controllers/*.ts'], {eager: true})

for (const [path, module] of Object.entries(controllerModules)) {
  const dirs = path.split('/')

  // Dropping ../controllers to end up
  // with something like "ariadne-component-name"
  const name = dirs.slice(2, dirs.length).join('-').replace('.ts', '').replaceAll('_', '-').toLocaleLowerCase()

  application.register(
    // @tag stimulus-id
    `ariadne-${name}`,
    (module as {default: ControllerConstructor}).default,
  )
}

export {application}

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.80.3 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.79.2 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.79.1 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.79 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.78 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.77 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.76.1 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.76 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.75 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.74.1 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.74 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.73 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.72 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.71 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.70 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.69 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.68 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.67 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.66 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.65 app/frontend/ariadne/stimulus_app.ts