Sha256: 223f991b9060de17cf3bed518b60cb3eaa84b0972a22949a9013ae5457b94530

Contents?: true

Size: 1.42 KB

Versions: 25

Compression:

Stored size: 1.42 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-controllername"
  const name = dirs[dirs.length - 1].replace('_controller.ts', '').replaceAll('_', '-').toLocaleLowerCase()

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

export {application}

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.92 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.91 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.90 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.89.1 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.89 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.88 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.87 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.86.9 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.86.8 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.86.7 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.86.6 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.86.5 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.86.4 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.86.3 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.86.2 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.86.1 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.86 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.85 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.84 app/frontend/ariadne/stimulus_app.ts
ariadne_view_components-0.0.83.3 app/frontend/ariadne/stimulus_app.ts