improve intellisense
This commit is contained in:
parent
ac412b798c
commit
6a5addb383
15 changed files with 39393 additions and 483 deletions
|
|
@ -1,5 +1,8 @@
|
|||
import { Namespace } from "../types/vanilla/elements.js"
|
||||
import { IntelliSense } from "../types/vanilla/intellisense.js"
|
||||
import { IntelliSense, Namespace, Element, VanillaType } from "../types/vanilla/intellisense.js"
|
||||
import { paths } from "../types/vanilla/paths.js"
|
||||
import { UI } from "./UI.js"
|
||||
|
||||
export function Modify<T extends Namespace>(namespace: T, name: IntelliSense[T]) {}
|
||||
export function Modify<T extends Namespace, K extends Element<T>>(namespace: T, name: K) {
|
||||
// @ts-ignore -- TS cannot prove this, but runtime guarantees it
|
||||
return new UI<VanillaType<T, K>>(undefined, name, namespace, paths[namespace][name])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,22 +3,30 @@ import { Memory } from "../compilers/Memory.js"
|
|||
import { Renderer } from "../types/enums/Renderer.js"
|
||||
import { Type } from "../types/enums/Type.js"
|
||||
import { Properties } from "../types/properties/components.js"
|
||||
import { Namespace, VanillaType } from "../types/vanilla/intellisense.js"
|
||||
import { Class } from "./Class.js"
|
||||
import { RandomString } from "./Utils.js"
|
||||
|
||||
import util from "node:util"
|
||||
|
||||
export class UI<T extends Type, K extends Renderer | null = null> extends Class {
|
||||
private path: string
|
||||
path: string
|
||||
|
||||
name: string
|
||||
namespace: string
|
||||
extend?: UI<Type, Renderer | null>
|
||||
|
||||
canExtend: boolean
|
||||
|
||||
controls = new Map<string, [UI<Type, Renderer | null>, Properties<Type, Renderer | null>]>()
|
||||
properties: Properties<T, K> = <any>{}
|
||||
|
||||
constructor(public type?: T, name?: string, namespace?: string, path?: string) {
|
||||
constructor(
|
||||
public type?: T,
|
||||
name?: string,
|
||||
namespace?: string,
|
||||
path?: string,
|
||||
) {
|
||||
super()
|
||||
|
||||
if (name === "namespace") {
|
||||
|
|
@ -26,12 +34,14 @@ export class UI<T extends Type, K extends Renderer | null = null> extends Class
|
|||
process.exit(1)
|
||||
}
|
||||
|
||||
this.name = name?.match(/^\w+/)?.[0] || RandomString(16)
|
||||
this.name = name?.match(/^(\w|\/)+/)?.[0] || RandomString(16)
|
||||
this.namespace = namespace || RandomString(16)
|
||||
|
||||
if (!path) this.path = `@/${this.namespace}`
|
||||
else this.path = path
|
||||
|
||||
this.canExtend = this.name.search("/") === -1
|
||||
|
||||
Memory.register_ui(this.path, this)
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +89,7 @@ export class UI<T extends Type, K extends Renderer | null = null> extends Class
|
|||
}
|
||||
|
||||
return `\x1b[33mUI\x1b[0m<\x1b[92m${
|
||||
this.type || `${this.extend}`
|
||||
this.type || this.extend ? `${this.extend}` : "ANY"
|
||||
}\x1b[0m> \x1b[92m"${this}\x1b[92m"\x1b[0m ${util.inspect(obj, opts)}\n`
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ export function Custom<R extends Renderer>(
|
|||
renderer: R,
|
||||
properties?: Properties<Type.CUSTOM, R>,
|
||||
name?: string,
|
||||
namespace?: string
|
||||
namespace?: string,
|
||||
) {
|
||||
const custom = new UI<Type.CUSTOM, R>(Type.CUSTOM, name, namespace)
|
||||
if (properties) custom.setProperties({ renderer, ...properties })
|
||||
|
|
@ -171,8 +171,11 @@ export function Extends<T extends Type, K extends Renderer | null>(
|
|||
element: UI<T, K>,
|
||||
properties?: Properties<T, K>,
|
||||
name?: string,
|
||||
namespace?: string
|
||||
namespace?: string,
|
||||
) {
|
||||
if (!element.canExtend) {
|
||||
throw new Error("Cannot extend a UI that cannot be extended")
|
||||
}
|
||||
const ui = new UI<T, K>(undefined, name, namespace)
|
||||
if (properties) ui.setProperties(properties)
|
||||
ui.extend = element
|
||||
|
|
|
|||
|
|
@ -1,35 +1,36 @@
|
|||
export enum Type {
|
||||
SELECTION_WHEEL = "selection_wheel",
|
||||
PANEL = "panel",
|
||||
SCREEN = "screen",
|
||||
STACK_PANEL = "stack_panel",
|
||||
LABEL = "label",
|
||||
IMAGE = "image",
|
||||
INPUT_PANEL = "input_panel",
|
||||
CUSTOM = "custom",
|
||||
GRID = "grid",
|
||||
FACTORY = "factory",
|
||||
BUTTON = "button",
|
||||
TOGGLE = "toggle",
|
||||
SLIDER = "slider",
|
||||
EDIT_BOX = "edit_box",
|
||||
DROPDOWN = "dropdown",
|
||||
SCROLL_VIEW = "scroll_view",
|
||||
SLIDER_BOX = "slider_box",
|
||||
SCROLLBAR_BOX = "scrollbar_box",
|
||||
SCROLL_TRACK = "scroll_track",
|
||||
GRID_PAGE_INDICATOR = "grid_page_indicator",
|
||||
IMAGE_CYCLER = "image_cycler",
|
||||
LABEL_CYCLER = "label_cycler",
|
||||
COLLECTION_PANEL = "collection_panel",
|
||||
TOOLTIP_TRIGGER = "tooltip_trigger",
|
||||
TAB = "tab",
|
||||
CAROUSEL_LABEL = "carousel_label",
|
||||
COMBOX = "combox",
|
||||
LAYOUT = "layout",
|
||||
STACK_GRID = "stack_grid",
|
||||
JOYSTICK = "joystick",
|
||||
RICH_TEXT = "rich_text",
|
||||
SIXTEEN_NINE_LAYOUT = "sixteen_nine_layout",
|
||||
MUL_LINES = "mul_lines",
|
||||
}
|
||||
SELECTION_WHEEL = "selection_wheel",
|
||||
PANEL = "panel",
|
||||
SCREEN = "screen",
|
||||
STACK_PANEL = "stack_panel",
|
||||
LABEL = "label",
|
||||
IMAGE = "image",
|
||||
INPUT_PANEL = "input_panel",
|
||||
CUSTOM = "custom",
|
||||
GRID = "grid",
|
||||
FACTORY = "factory",
|
||||
BUTTON = "button",
|
||||
TOGGLE = "toggle",
|
||||
SLIDER = "slider",
|
||||
EDIT_BOX = "edit_box",
|
||||
DROPDOWN = "dropdown",
|
||||
SCROLL_VIEW = "scroll_view",
|
||||
SLIDER_BOX = "slider_box",
|
||||
SCROLLBAR_BOX = "scrollbar_box",
|
||||
SCROLL_TRACK = "scroll_track",
|
||||
GRID_PAGE_INDICATOR = "grid_page_indicator",
|
||||
IMAGE_CYCLER = "image_cycler",
|
||||
LABEL_CYCLER = "label_cycler",
|
||||
COLLECTION_PANEL = "collection_panel",
|
||||
TOOLTIP_TRIGGER = "tooltip_trigger",
|
||||
TAB = "tab",
|
||||
CAROUSEL_LABEL = "carousel_label",
|
||||
COMBOX = "combox",
|
||||
LAYOUT = "layout",
|
||||
STACK_GRID = "stack_grid",
|
||||
JOYSTICK = "joystick",
|
||||
RICH_TEXT = "rich_text",
|
||||
SIXTEEN_NINE_LAYOUT = "sixteen_nine_layout",
|
||||
MUL_LINES = "mul_lines",
|
||||
UNKNOWN = "unknown",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { AnimValue, Array2, Binding, PropertyBags, Value, Variable } from "../va
|
|||
|
||||
export interface Control {
|
||||
visible?: Value<boolean>
|
||||
ignored?: Value<boolean>
|
||||
enabled?: Value<boolean>
|
||||
layer?: Value<number>
|
||||
z_order?: Value<number>
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,2 +1 @@
|
|||
export * from "./elements.js"
|
||||
export * from "./intellisense.js"
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
19435
src/types/vanilla/paths.ts
Normal file
19435
src/types/vanilla/paths.ts
Normal file
File diff suppressed because it is too large
Load diff
Reference in a new issue