This repository has been archived by the owner on Dec 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christopher Mühl
committed
Apr 8, 2021
1 parent
36b70b4
commit 74b7375
Showing
5 changed files
with
64 additions
and
82 deletions.
There are no files selected for viewing
12 changes: 1 addition & 11 deletions
12
packages/awtrix/templates/core/apps/awtrix/0.0.1/backend.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
const { Yeelight } = require('yeelight-node') | ||
|
||
module.exports = (BaseClass) => { | ||
return class extends BaseClass { | ||
register () { | ||
const light = new Yeelight({ ip: '10.0.0.51', port: 55443 }) | ||
|
||
this.io.on('connect', (client) => { | ||
client.on('toggle', (ctx) => { | ||
light.toggle() | ||
}) | ||
}) | ||
} | ||
register () { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { | ||
defineComponent, | ||
ComponentOptionsWithoutProps, | ||
ComponentOptionsWithObjectProps, | ||
ComponentOptionsWithArrayProps, | ||
ComponentOptionsMixin, | ||
ComputedOptions, | ||
MethodOptions, | ||
ComponentPropsOptions, | ||
EmitsOptions | ||
} from 'vue' | ||
import FrontendApp from './FrontendApp' | ||
|
||
export type GeneratorType = ((base: typeof FrontendApp) => ReturnType<typeof FrontendApp.extend>) & { options: any } | ||
|
||
// Define function overloads for the extend function. These are necessary to | ||
// allow for proper TypeScript typing and auto-completion. This basically | ||
// copies the overloaded function types from the @vue/runtime-core package. | ||
// The three possible argument types are: | ||
|
||
/** | ||
* Creates a new Vue component that inherits from the Awtrix HD FrontendApp. | ||
* | ||
* @param options | ||
* @returns GeneratorType | ||
*/ | ||
function extend<Props = {}, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = typeof FrontendApp, E extends EmitsOptions = EmitsOptions, EE extends string = string> | ||
(options: ComponentOptionsWithoutProps<Props, RawBindings, D, C, M, Mixin, Extends, E, EE>): GeneratorType | ||
|
||
/** | ||
* Creates a new Vue component that inherits from the Awtrix HD FrontendApp. | ||
* | ||
* @param options | ||
* @returns GeneratorType | ||
*/ | ||
function extend<PropNames extends string, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = typeof FrontendApp, E extends EmitsOptions = Record<string, any>, EE extends string = string> | ||
(options: ComponentOptionsWithArrayProps<PropNames, RawBindings, D, C, M, Mixin, Extends, E, EE>): GeneratorType | ||
|
||
/** | ||
* Creates a new Vue component that inherits from the Awtrix HD FrontendApp. | ||
* | ||
* @param options | ||
* @returns GeneratorType | ||
*/ | ||
function extend<PropsOptions extends Readonly<ComponentPropsOptions>, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = typeof FrontendApp, E extends EmitsOptions = Record<string, any>, EE extends string = string> | ||
(options: ComponentOptionsWithObjectProps<PropsOptions, RawBindings, D, C, M, Mixin, Extends, E, EE>): GeneratorType | ||
|
||
// Finally the function implementation. | ||
function extend(options: any): GeneratorType { | ||
const generatorFunction = (base: typeof FrontendApp) => defineComponent({ ...options, extends: base }) | ||
|
||
// `vue-loader` creates a `render` function and attaches it to the exported function's | ||
// `options` property. If the exported function is a Vue constructor that is fine. We | ||
// are dealing with our custom generator function however, so we need to add the | ||
// `options` property as well. We will then override the actual render function after | ||
// loading the component in our frontend. | ||
Object.assign(generatorFunction, { options: {} }) | ||
return generatorFunction as GeneratorType | ||
} | ||
|
||
export default extend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,4 @@ | ||
export { GeneratorType, default as createFrontend } from './createFrontend' | ||
export { GeneratorType, default as defineComponent } from './defineComponent' | ||
export { default as BackendApp } from './BackendApp' | ||
export { default as FrontendApp } from './FrontendApp' | ||
import { foobar } from './createFrontend' | ||
export * as Types from './types' | ||
|
||
foobar({ | ||
data () { | ||
return { | ||
nuddel: 'foa' | ||
} | ||
}, | ||
|
||
created () { | ||
this.nuddel | ||
this.lock() | ||
} | ||
}) |