Comments (2)
Dome Module Imports
For simplifying code reutilization and modularization,
this is a proposed way for DOME to handle dependencies.
modules.wren
This is a simple wren file that contains
each module path. Is inspired on https://github.com/WICG/import-maps
var Imports = {
"domepunk": "modules/domepunk/dp.wren",
"domepunk/": "modules/domepunk", // allow imports for files inside the domepunk/ dir
}
On startup DOME will load this file (if exists) and store the paths for reference later
when loading imports
inside wren files.
The filename could be overrited using --importmap=<FILE>
CLI flag.
tar files
Paths that end with tar will be considered as a tar file.
Using @
after the file extension it would mean a file inside the tar.
var Imports = {
"domepunk": "modules/domepunk.tar",
"domepunk/math": "modules/domepunk.tar@science/math"
}
importing
-
Using
@
at the start of the import will use the importmap path first. -
Without using
@
it would follow the traditional way of importing and use the importmap last for resolve it. -
If the paths begins with
/
("/domepunk") it would consider the base path of the dome executable. -
If the path does not begins with
/
("domepunk") it would consider the base path of the main.wren file. -
If the path begins with
./
("./domepunk") it would consider the base path of the current file begin executed.
// Will use the math module path defined in modules.wren
import "@math" for Math
// Will use the same path for the _dome_ executable as the base path. if not found will look into the modules.wren path
import "/math" for Math
// Will use the _file_ path as base path. Then it will look for the _main.wren_ base path. Then it will look for _modules.wren_ path. Finally it will look for the _dome_ executable base path.
import "./math" for Math
// First it will look for the internal modules. Then it will use the _main.wren_ base path. Then it will look for the _file_ base path. if not found will look into the modules.wren path. Finally it will use the _dome_ executable base path.
import "hello" for Hello
default name
Modules can define a default main.wren file that will be loaded by default if no file is specified for the path.
from dome.
Based on the proof on concept. This is the proposed algorithm for resolving imports.
-
First it resolves the import using the traditional way of the path based on main.wren.
-
If the file is not found then it will look inside a modules dir.
-
If the file is not found in modules directory then it will look for a path inside dome.ini.
-
finally it will trigger import error for file not found.
-
Example:
import "domepunk" for Dp
-
This first will look for a file named
domepunk.wren
in the base path of main.wren. -
Then it will look inside basepath/modules/domepunk.wren.
-
Then it will look inside basepath/modules/domepunk/domepunk.wren.
-
Then it will search for a key named
domepunk
inside dome.ini -
If a key is found then it will look for a file inside {dome.ini.path}/domepunk.wren
-
Example:
import "domepunk/utils/clock" for Clock
-
This first will look for a file named
clock.wren
in the base path/domepunk/utils of main.wren. -
Then it will look inside basepath/modules/domepunk/utils/clock.wren.
-
Then it will search for a key named
domepunk
inside dome.ini -
If a key is found then it will look for a file inside {dome.ini.path}/utils/clock.wren
-
Example:
import "../domepunk/utils/clock" for Clock
-
This first will look for a file named
../clock.wren
in the base path/../domepunk/utils of main.wren. -
Special paths like
./
or../
are omited in the modules search after the traditional way. -
Then it will look inside basepath/modules/domepunk/utils/clock.wren.
-
Then it will search for a key named
domepunk
inside dome.ini -
If a key is found then it will look for a file inside {dome.ini.path}/utils/clock.wren
-
Example dome.ini
[imports]
domepunk = examples/
from dome.
Related Issues (20)
- `Canvas.font` for retrieving the current font HOT 2
- Error dialogs can be annoying during development
- Update random module to accommodate algorithm updates HOT 2
- Possible Memory Leak in Canvas HOT 1
- Linking fails on ElementaryOS / Raspberry PI HOT 4
- graphicsApi: Canvas does not resize after init HOT 1
- Add `justReleased` to get when a key has been released
- DOME doesn't handle absolute paths correctly for an entry point
- Canvas.clip crashes if the Canvas has been resized
- Plugin: DOME_Color.value seems to be ordered as 0xAABBGGRR but docs say It's 0xAARRGGBB HOT 5
- Modules with a filename the same as internal modules aren't read HOT 1
- When using offsets and clipping regions, an x less than 0 underflows to the previous row
- Scale dome.html viewport HOT 4
- ImageData rendered partially offscreen to the left would snap to x=0 HOT 1
- DOME v1.8.0's Mac build is actually for aarch64 (M1+) rather than x86_64 or a Universal Build
- When taking a screenshot using the built-in mechanism,, DOME overwrites the old one
- Windows - Dome Fails to load files from other Drives HOT 3
- Log level can't be set to "debug"
- Resizing the Canvas without clearing it sometimes causes artifacting
- DOME can't play all MP3s
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dome.