I'm building ViewScript, a tool for rapidly launching simple web apps.
alexyuly / viewscript-runtime Goto Github PK
View Code? Open in Web Editor NEWInterpreter for ViewScript code
Home Page: https://www.viewscript.dev
License: MIT License
Interpreter for ViewScript code
Home Page: https://www.viewscript.dev
License: MIT License
I'm building ViewScript, a tool for rapidly launching simple web apps.
ElementEventPublisher
ArrayField
:
Methods are members of a model bound to another method or a field, with a return type (data) and an optional parameter type (data or function), which are referenced by inputs.
Should we support controlled inputs, like React? Most likely this is useful in many cases so yes we should.
Prerequisite for #11
The groundwork for structures is in place, but their children need to be dynamic (fields)
Proposal:
Allow Field["value"]
to be null
. This indicates a private, empty field; as opposed to a value of undefined
, which is already allowed, and which indicates a public field, whose value will come from the parent element.
Add functionality to the Field type, such that the value of a Field instance is optional when the Field instance is provided to a Let or Take instance.
export type Action<Parameter extends Model = Model> = Node<"action"> & {
parameter?: Named & Field<Parameter>;
steps: Array<ActionPointer | Exception | StreamPointer>;
};
export type ActionPointer<Parameter extends Model = Model> =
Node<"actionPointer"> & {
actionPath: Array<string>;
argument?: Field<Parameter>;
};
export type Model<Name extends string = string> = Node<"model"> &
Named<Name> & {
members: Record<string, Field | Method | Action>;
};
export type Atom = Node<"atom"> & {
tagName: string;
properties: Record<string, Action | Field>;
};
export type Organism<T extends View = View> = Node<"organism"> & {
viewName: T["name"];
properties: {
[Key in keyof T["members"]]?: T["members"][Key] extends Stream<infer Event>
? Action<Event>
: T["members"][Key];
};
};
Currently, this will throw an error about "private fields".
Does this make sense?
(How) do we want to handle "optional" properties? With a special case, i.e. public fields with an initializer? Or, let all view fields be publicly set by parent elements?
export type Exception = Node<"exception"> & {
condition: Field<Model<"Boolean">>;
steps?: Array<ActionPointer | Exception | StreamPointer>;
};
to help support calling native actions and methods on window
for example calls to window.fetch
which pass a URL and options
the calls to setTimeout
and setInterval
in the example in #23
In TodoListApp.d.ts
:
I want to update completed: Let<BooleanModel>;
to `completed: Let<BooleanModel, false>;
However, the second type argument of Let
causes an error in all cases except void
. Something is broken about how DataType
works, but I don't know what.
View
, line 553 at this timeA task has a contract with outputs and data (like a view), and also actions.
Additionally, a task calls its own stop
and start
actions:
stop
runs just before a task 1) shuts down or 2) receives an updated contract.start
runs just after a task 1) starts up or 2) receives an updated contract.Here's an example task which defines a timer (to be implemented for v0.5)...
export Timer = task {
looping: boolean or false
paused: boolean or false
period: number
time: output
id = 0
stop = window.(clearTimeout id)
start = do {
when paused do nothing
when looping do id.(setTo window.(setInterval time period))
id.(setTo window.(setTimeout time period))
}
}
An operation is a new instance of a task, for example:
myTimer = Timer {
looping = true
period = 1000
time = window.console.(log "The timer went off again!")
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.