chore: 3.0.0
This commit is contained in:
parent
c7f4039836
commit
c9d3f6f8e6
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -114,3 +114,5 @@ dist
|
|||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
/packages/*/yarn.lock
|
||||
|
|
8
config/package/.gitignore
vendored
8
config/package/.gitignore
vendored
|
@ -1,8 +0,0 @@
|
|||
**/*.js
|
||||
**/*.map
|
||||
/assets
|
||||
!/.*
|
||||
!/postcss.config.js
|
||||
!/webpack.config.js
|
||||
!src/**/*.js
|
||||
!/test/**/*.js
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "latus-build",
|
||||
"clean": "latus-build clean",
|
||||
"fp": "latus-build forcepublish",
|
||||
"lint": "latus-build lint",
|
||||
"test": "latus-build test"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.js.map",
|
||||
"test.js",
|
||||
"test.js.map"
|
||||
],
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@latus/build": "1.x"
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
import {expect} from 'chai';
|
||||
|
||||
it('exists', () => {
|
||||
expect(true).to.be.true;
|
||||
});
|
|
@ -2,5 +2,5 @@
|
|||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "1.0.0"
|
||||
"version": "3.0.0"
|
||||
}
|
||||
|
|
37
package.js
37
package.js
|
@ -1,37 +0,0 @@
|
|||
const {execSync} = require('child_process');
|
||||
const {join} = require('path');
|
||||
const fs = require('fs-extra')
|
||||
|
||||
const cwd = process.cwd();
|
||||
const [exe, script, package] = process.argv;
|
||||
|
||||
const path = join(cwd, 'packages', package);
|
||||
try {
|
||||
fs.accessSync(path);
|
||||
console.error(`Package '${package}' already exists, aborting.`);
|
||||
process.exit(1);
|
||||
}
|
||||
catch (error) {}
|
||||
|
||||
const [scope] = require('./package.json').name.split('/');
|
||||
const name = [scope, package].join('/');
|
||||
console.log(`Copying new project '${name}' to ${path}...`);
|
||||
fs.copySync(
|
||||
join(cwd, 'config/package'),
|
||||
path,
|
||||
);
|
||||
const json = {
|
||||
...require(join(path, 'package.json')),
|
||||
name,
|
||||
};
|
||||
fs.writeFileSync(
|
||||
join(path, 'package.json'),
|
||||
JSON.stringify(json, null, 2),
|
||||
);
|
||||
|
||||
const exec = (cmd) => execSync(cmd, {cwd: path, stdio: 'inherit'});
|
||||
console.log(`Installing...`);
|
||||
exec('yarn');
|
||||
|
||||
console.log(`Testing...`);
|
||||
exec('yarn run test');
|
25
package.json
25
package.json
|
@ -1,19 +1,24 @@
|
|||
{
|
||||
"name": "@avocado/monorepo",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.hq.cha0s.io/cha0s/avocado.git"
|
||||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "lerna run build",
|
||||
"clean": "lerna run clean --concurrency=1",
|
||||
"dev": "lerna run dev",
|
||||
"fp": "lerna run fp",
|
||||
"lint": "lerna run lint",
|
||||
"package": "node ./package.js",
|
||||
"refresh": "yarn run clean && npx lerna exec link-all && yarn run build && yarn run test",
|
||||
"test": "lerna run test --no-bail -- --silent",
|
||||
"watch": "lerna run watch --parallel"
|
||||
"build": "FLECKS_ENV_FLECKS_SERVER_start=0 npm run build:only",
|
||||
"build:only": "flecks build",
|
||||
"debug": "DEBUG=*,-babel* npm run dev",
|
||||
"dev": "npm run -- build:only -hv",
|
||||
"link-all": "yarn link $(for i in $(ls node_modules/@flecks); do echo -n \"@flecks/$i \"; done)",
|
||||
"postinstall": "patch-package",
|
||||
"repl": "npx flecks repl --rlwrap",
|
||||
"start": "DEBUG=@flecks*,honeybee,-@flecks/core/flecks* npm run dev",
|
||||
"unlink-all": "yarn unlink $(for i in $(ls node_modules/@flecks); do echo -n \"@flecks/$i \"; done) && yarn install --force",
|
||||
"up": "yarn add $(for i in $(ls node_modules/@flecks); do echo -n \"@flecks/$i \"; done)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@latus/build": "1.x",
|
||||
"@flecks/create-fleck": "^1.3.0",
|
||||
"lerna": "^3.22.1"
|
||||
}
|
||||
}
|
||||
|
|
124
packages/behavior-persea/.gitignore
vendored
124
packages/behavior-persea/.gitignore
vendored
|
@ -1,8 +1,116 @@
|
|||
**/*.js
|
||||
**/*.map
|
||||
/assets
|
||||
!/.*
|
||||
!/postcss.config.js
|
||||
!/webpack.config.js
|
||||
!src/**/*.js
|
||||
!/test/**/*.js
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
|
6
packages/behavior-persea/build/flecks.yml
Normal file
6
packages/behavior-persea/build/flecks.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
'@flecks/core': {}
|
||||
'@flecks/fleck': {}
|
||||
'@flecks/http': {}
|
||||
'@flecks/http/server':
|
||||
build: false
|
||||
'@flecks/react': {}
|
|
@ -1,28 +1,38 @@
|
|||
{
|
||||
"version": "1.0.0",
|
||||
"name": "@avocado/behavior-persea",
|
||||
"version": "3.0.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.hq.cha0s.io/cha0s/avocado.git",
|
||||
"directory": "packages/behavior-persea"
|
||||
},
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "latus-build",
|
||||
"clean": "latus-build clean",
|
||||
"fp": "latus-build forcepublish",
|
||||
"lint": "latus-build lint",
|
||||
"test": "latus-build test"
|
||||
"build": "flecks build",
|
||||
"clean": "flecks clean",
|
||||
"lint": "flecks lint",
|
||||
"postversion": "cp package.json dist",
|
||||
"test": "flecks test"
|
||||
},
|
||||
"files": [
|
||||
"build",
|
||||
"index.js",
|
||||
"index.js.map",
|
||||
"src",
|
||||
"test",
|
||||
"test.js",
|
||||
"test.js.map"
|
||||
],
|
||||
"dependencies": {
|
||||
"@avocado/math-persea": "^1.0.0",
|
||||
"@avocado/react": "^1.0.0",
|
||||
"@avocado/resource-persea": "^1.0.0",
|
||||
"@latus/react": "^2.0.0",
|
||||
"@avocado/math-persea": "^3.0.0",
|
||||
"@avocado/react": "^3.0.0",
|
||||
"@avocado/resource-persea": "^3.0.0",
|
||||
"@flecks/core": "^1.3.0",
|
||||
"@flecks/react": "^1.3.0",
|
||||
"natsort": "^2.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@latus/build": "1.x"
|
||||
},
|
||||
"name": "@avocado/behavior-persea"
|
||||
"@flecks/fleck": "^1.3.0",
|
||||
"@flecks/http": "^1.3.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import {useJsonPatcher} from '@avocado/resource-persea';
|
|||
import {
|
||||
PropTypes,
|
||||
React,
|
||||
} from '@latus/react';
|
||||
} from '@flecks/react';
|
||||
|
||||
const ScriptComponent = ({path, resource}) => {
|
||||
const patch = useJsonPatcher();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {gatherComponents} from '@latus/react';
|
||||
import {Flecks, Hooks} from '@flecks/core';
|
||||
|
||||
import ScriptController from './controllers/script';
|
||||
|
||||
|
@ -7,12 +7,13 @@ export {
|
|||
};
|
||||
|
||||
export default {
|
||||
hooks: {
|
||||
'@avocado/resource-persea/controllers': () => [
|
||||
[Hooks]: {
|
||||
'@avocado/resource-persea.controllers': () => [
|
||||
ScriptController,
|
||||
],
|
||||
'@avocado/traits-persea/components': gatherComponents(
|
||||
'@avocado/traits-persea.components': Flecks.provide(
|
||||
require.context('./traits', false, /\.jsx$/),
|
||||
{invoke: false},
|
||||
),
|
||||
},
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
Tabs,
|
||||
TabList,
|
||||
TabPanel,
|
||||
} from '@latus/react';
|
||||
} from '@flecks/react';
|
||||
import {Code} from '@avocado/react';
|
||||
|
||||
const Behaved = ({
|
||||
|
|
File diff suppressed because it is too large
Load Diff
122
packages/behavior/.gitignore
vendored
122
packages/behavior/.gitignore
vendored
|
@ -1,6 +1,116 @@
|
|||
**/*.js
|
||||
**/*.map
|
||||
/assets
|
||||
!/.*
|
||||
!src/**/*.js
|
||||
!/test/**/*.js
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
|
|
@ -1,32 +1,40 @@
|
|||
{
|
||||
"name": "@avocado/behavior",
|
||||
"version": "2.0.0",
|
||||
"version": "3.0.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.hq.cha0s.io/cha0s/avocado.git",
|
||||
"directory": "packages/behavior"
|
||||
},
|
||||
"main": "index.js",
|
||||
"author": "cha0s",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "latus-build",
|
||||
"clean": "latus-build clean",
|
||||
"fp": "latus-build forcepublish",
|
||||
"lint": "latus-build lint",
|
||||
"test": "latus-build test"
|
||||
"build": "flecks build",
|
||||
"clean": "flecks clean",
|
||||
"lint": "flecks lint",
|
||||
"postversion": "cp package.json dist",
|
||||
"test": "flecks test"
|
||||
},
|
||||
"files": [
|
||||
"build",
|
||||
"index.js",
|
||||
"index.js.map",
|
||||
"src",
|
||||
"test",
|
||||
"test.js",
|
||||
"test.js.map"
|
||||
],
|
||||
"dependencies": {
|
||||
"@avocado/core": "2.0.0",
|
||||
"@avocado/resource": "^2.0.0",
|
||||
"@avocado/sandbox": "^1.0.0",
|
||||
"@avocado/traits": "^2.0.0",
|
||||
"@avocado/core": "^3.0.0",
|
||||
"@avocado/resource": "^3.0.0",
|
||||
"@avocado/traits": "^3.0.0",
|
||||
"@babel/parser": "^7.13.13",
|
||||
"@latus/core": "2.0.0",
|
||||
"@flecks/core": "^1.3.0",
|
||||
"babeler": "^1.0.0",
|
||||
"lru-cache": "^6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@latus/build": "1.x"
|
||||
"@flecks/fleck": "^1.3.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import {TickingPromise} from '@avocado/core';
|
||||
|
||||
export default (latus) => ({
|
||||
export default (flecks) => ({
|
||||
console,
|
||||
latus,
|
||||
SIDE: process.env.SIDE,
|
||||
flecks,
|
||||
FLECKS_CORE_BUILD_TARGET: process.env.FLECKS_CORE_BUILD_TARGET,
|
||||
TickingPromise,
|
||||
wait: (duration) => new TickingPromise(
|
||||
(resolve) => {
|
||||
|
|
|
@ -1,37 +1,14 @@
|
|||
import {gatherWithLatus} from '@latus/core';
|
||||
import {Flecks, Hooks} from '@flecks/core';
|
||||
|
||||
import globals from './globals';
|
||||
|
||||
export default {
|
||||
hooks: {
|
||||
'@avocado/behavior/globals': globals,
|
||||
'@avocado/resource/resources': gatherWithLatus(
|
||||
require.context('./resources', false, /\.js$/),
|
||||
),
|
||||
'@avocado/traits/traits': gatherWithLatus(
|
||||
require.context('./traits', false, /\.js$/),
|
||||
),
|
||||
'@latus/core/starting': async (latus) => {
|
||||
latus.set('%behaviorCompilers', latus.invokeReduce('@avocado/behavior/compilers'));
|
||||
latus.set('%behaviorGlobals', latus.invokeReduce('@avocado/behavior/globals'));
|
||||
const types = (await latus.invokeOrdered('@avocado/behavior/types'))
|
||||
.reduce((r, types) => ({...r, ...types}), {});
|
||||
latus.set(
|
||||
'%behavior-types',
|
||||
latus.invokeComposed('@avocado/behavior/types.decorate', types),
|
||||
);
|
||||
[Hooks]: {
|
||||
'@avocado/behavior.globals': globals,
|
||||
'@avocado/resource.resources': Flecks.provide(require.context('./resources', false, /\.js$/)),
|
||||
'@avocado/traits.traits': Flecks.provide(require.context('./traits', false, /\.js$/)),
|
||||
'@flecks/core.starting': async (flecks) => {
|
||||
flecks.set('$avocado/behavior.globals', flecks.invokeMerge('@avocado/behavior.globals'));
|
||||
},
|
||||
'@latus/core/config': () => ({
|
||||
types: [
|
||||
'@avocado/math',
|
||||
'@avocado/entity',
|
||||
'@avocado/timing',
|
||||
// ...
|
||||
'@avocado/behavior',
|
||||
],
|
||||
'types.decorate': [
|
||||
'@avocado/timing',
|
||||
],
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import {TickingPromise} from '@avocado/core';
|
||||
import {Resource} from '@avocado/resource';
|
||||
import {Sandbox} from '@avocado/sandbox';
|
||||
import {parse} from '@babel/parser';
|
||||
import {compose, EventEmitter} from '@latus/core';
|
||||
import {compose, EventEmitter} from '@flecks/core';
|
||||
import {Sandbox} from 'babeler';
|
||||
import LRU from 'lru-cache';
|
||||
|
||||
const Populated = Symbol.for('@avocado/behavior.populated');
|
||||
|
||||
const cache = 'production' === process.env.NODE_ENV
|
||||
? new LRU({
|
||||
max: 128,
|
||||
|
@ -25,7 +27,7 @@ const empty = {
|
|||
},
|
||||
};
|
||||
|
||||
export default (latus) => {
|
||||
export default (flecks) => {
|
||||
const decorate = compose(
|
||||
EventEmitter,
|
||||
);
|
||||
|
@ -47,12 +49,12 @@ export default (latus) => {
|
|||
}
|
||||
|
||||
static createContext(locals = {}) {
|
||||
if (locals.__populated) {
|
||||
if (locals[Populated]) {
|
||||
return locals;
|
||||
}
|
||||
return {
|
||||
__populated: true,
|
||||
...latus.get('%behaviorGlobals'),
|
||||
[Populated]: true,
|
||||
...flecks.get('$avocado/behavior.globals'),
|
||||
...locals,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
import {Sandbox} from '@avocado/sandbox';
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import {mapValuesAsync} from '@avocado/core';
|
||||
import {StateProperty, Trait} from '@avocado/traits';
|
||||
import {compose} from '@latus/core';
|
||||
import {compose} from '@flecks/core';
|
||||
|
||||
const decorate = compose(
|
||||
StateProperty('activeCollective'),
|
||||
|
@ -12,7 +12,7 @@ const decorate = compose(
|
|||
|
||||
const STATIC_INTERVAL = 0.25;
|
||||
|
||||
export default (latus) => class Behaved extends decorate(Trait) {
|
||||
export default (flecks) => class Behaved extends decorate(Trait) {
|
||||
|
||||
#accumulator = 0;
|
||||
|
||||
|
@ -31,7 +31,7 @@ export default (latus) => class Behaved extends decorate(Trait) {
|
|||
({
|
||||
currentRoutine: this.#currentRoutine,
|
||||
} = this.constructor.defaultState());
|
||||
const {Script} = latus.get('%resources');
|
||||
const {Script} = flecks.get('$avocado/resource.resources');
|
||||
this.#context = Script.createContext();
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ export default (latus) => class Behaved extends decorate(Trait) {
|
|||
|
||||
static async loadScripts(scripts, context) {
|
||||
return mapValuesAsync(scripts, async (codeOrUri) => {
|
||||
const {Script} = latus.get('%resources');
|
||||
const {Script} = flecks.get('$avocado/resource.resources');
|
||||
const script = await Script.load(codeOrUri);
|
||||
script.context = context;
|
||||
return script;
|
||||
|
@ -143,7 +143,7 @@ export default (latus) => class Behaved extends decorate(Trait) {
|
|||
|
||||
async load(json) {
|
||||
await super.load(json);
|
||||
const {Script} = latus.get('%resources');
|
||||
const {Script} = flecks.get('$avocado/resource.resources');
|
||||
this.#context = Script.createContext({
|
||||
entity: this.entity,
|
||||
});
|
||||
|
@ -154,7 +154,7 @@ export default (latus) => class Behaved extends decorate(Trait) {
|
|||
this.#daemons = Object.values(await this.constructor.loadScripts(daemons, this.#context));
|
||||
this.#routines = await this.constructor.loadScripts(this.params.routines, this.#context);
|
||||
this.updateCurrentRoutine(this.state.currentRoutine);
|
||||
super.isBehaving = 'client' !== process.env.SIDE;
|
||||
super.isBehaving = 'http' !== process.env.FLECKS_CORE_BUILD_TARGET;
|
||||
}
|
||||
|
||||
methods() {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
122
packages/color/.gitignore
vendored
122
packages/color/.gitignore
vendored
|
@ -1,6 +1,116 @@
|
|||
**/*.js
|
||||
**/*.map
|
||||
/assets
|
||||
!/.*
|
||||
!src/**/*.js
|
||||
!/test/**/*.js
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
|
|
@ -1,29 +1,36 @@
|
|||
{
|
||||
"name": "@avocado/color",
|
||||
"version": "1.0.0",
|
||||
"version": "3.0.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.hq.cha0s.io/cha0s/avocado.git",
|
||||
"directory": "packages/color"
|
||||
},
|
||||
"main": "index.js",
|
||||
"author": "cha0s",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "latus-build",
|
||||
"clean": "latus-build clean",
|
||||
"fp": "latus-build forcepublish",
|
||||
"lint": "latus-build lint",
|
||||
"test": "latus-build test"
|
||||
"build": "flecks build",
|
||||
"clean": "flecks clean",
|
||||
"lint": "flecks lint",
|
||||
"postversion": "cp package.json dist",
|
||||
"test": "flecks test"
|
||||
},
|
||||
"files": [
|
||||
"build",
|
||||
"index.js",
|
||||
"index.js.map",
|
||||
"src",
|
||||
"test",
|
||||
"test.js",
|
||||
"test.js.map"
|
||||
],
|
||||
"dependencies": {
|
||||
"@avocado/traits": "^2.0.0",
|
||||
"@latus/core": "^2.0.0",
|
||||
"@flecks/core": "^1.3.0",
|
||||
"lodash.get": "^4.4.2",
|
||||
"lodash.set": "^4.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@latus/build": "1.x"
|
||||
"@flecks/fleck": "^1.3.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import {gatherWithLatus} from '@latus/core';
|
||||
import {Flecks, Hooks} from '@flecks/core';
|
||||
|
||||
import dialogFunctions from './dialog-functions';
|
||||
|
||||
export default {
|
||||
hooks: {
|
||||
'@avocado/dialog/functions': dialogFunctions,
|
||||
'@avocado/traits/traits': gatherWithLatus(
|
||||
require.context('./traits', false, /\.js$/),
|
||||
),
|
||||
[Hooks]: {
|
||||
'@avocado/dialog.functions': dialogFunctions,
|
||||
'@avocado/traits.traits': Flecks.provide(require.context('./traits', false, /\.js$/)),
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,128 +1,131 @@
|
|||
import {StateProperty, Trait} from '@avocado/traits';
|
||||
import {compose} from '@latus/core';
|
||||
import {compose} from '@flecks/core';
|
||||
|
||||
import hsv2rgb from '../hsv2rgb';
|
||||
import rgb2hsv from '../rgb2hsv';
|
||||
|
||||
const decorate = compose(
|
||||
StateProperty('red', {
|
||||
track: true,
|
||||
}),
|
||||
StateProperty('green', {
|
||||
track: true,
|
||||
}),
|
||||
StateProperty('blue', {
|
||||
track: true,
|
||||
}),
|
||||
);
|
||||
export default (flecks) => {
|
||||
const {StateProperty, Trait} = flecks.fleck('@avocado/traits');
|
||||
|
||||
export default () => class Colorized extends decorate(Trait) {
|
||||
const decorate = compose(
|
||||
StateProperty('red', {
|
||||
track: true,
|
||||
}),
|
||||
StateProperty('green', {
|
||||
track: true,
|
||||
}),
|
||||
StateProperty('blue', {
|
||||
track: true,
|
||||
}),
|
||||
);
|
||||
|
||||
static children() {
|
||||
return {
|
||||
red: {
|
||||
type: 'number',
|
||||
},
|
||||
green: {
|
||||
type: 'number',
|
||||
},
|
||||
blue: {
|
||||
type: 'number',
|
||||
},
|
||||
hue: {
|
||||
type: 'number',
|
||||
},
|
||||
saturation: {
|
||||
type: 'number',
|
||||
},
|
||||
value: {
|
||||
type: 'number',
|
||||
},
|
||||
};
|
||||
}
|
||||
return class Colorized extends decorate(Trait) {
|
||||
|
||||
get blue() {
|
||||
return this.state.blue;
|
||||
}
|
||||
|
||||
set blue(blue) {
|
||||
this.wrapRgbSet(() => {
|
||||
super.blue = blue;
|
||||
});
|
||||
}
|
||||
|
||||
static defaultState() {
|
||||
return {
|
||||
red: 0,
|
||||
green: 0,
|
||||
blue: 0,
|
||||
};
|
||||
}
|
||||
|
||||
get green() {
|
||||
return this.state.green;
|
||||
}
|
||||
|
||||
set green(green) {
|
||||
this.wrapRgbSet(() => {
|
||||
super.green = green;
|
||||
});
|
||||
}
|
||||
|
||||
get hue() {
|
||||
return rgb2hsv([this.red, this.green, this.blue])[0];
|
||||
}
|
||||
|
||||
set hue(hue) {
|
||||
this.wrapHsvSet(0, hue);
|
||||
}
|
||||
|
||||
get red() {
|
||||
return this.state.red;
|
||||
}
|
||||
|
||||
set red(red) {
|
||||
this.wrapRgbSet(() => {
|
||||
super.red = red;
|
||||
});
|
||||
}
|
||||
|
||||
get saturation() {
|
||||
return rgb2hsv([this.red, this.green, this.blue])[1];
|
||||
}
|
||||
|
||||
set saturation(saturation) {
|
||||
this.wrapHsvSet(1, saturation);
|
||||
}
|
||||
|
||||
get value() {
|
||||
return rgb2hsv([this.red, this.green, this.blue])[2];
|
||||
}
|
||||
|
||||
set value(value) {
|
||||
this.wrapHsvSet(2, value);
|
||||
}
|
||||
|
||||
wrapHsvSet(i, nv) {
|
||||
const hsv = rgb2hsv([this.red, this.green, this.blue]);
|
||||
const keys = ['hue', 'saturation', 'value'];
|
||||
if (nv !== hsv[i]) {
|
||||
hsv[i] = nv;
|
||||
[this.red, this.green, this.blue] = hsv2rgb(hsv);
|
||||
this.entity.emit(`${keys[i]}Changed`);
|
||||
static children() {
|
||||
return {
|
||||
red: {
|
||||
type: 'number',
|
||||
},
|
||||
green: {
|
||||
type: 'number',
|
||||
},
|
||||
blue: {
|
||||
type: 'number',
|
||||
},
|
||||
hue: {
|
||||
type: 'number',
|
||||
},
|
||||
saturation: {
|
||||
type: 'number',
|
||||
},
|
||||
value: {
|
||||
type: 'number',
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
wrapRgbSet(fn) {
|
||||
const o = rgb2hsv([this.red, this.green, this.blue]);
|
||||
fn();
|
||||
const n = rgb2hsv([this.red, this.green, this.blue]);
|
||||
['hue', 'saturation', 'value'].forEach((key, i) => {
|
||||
if (n[i] !== o[i]) {
|
||||
this.entity.emit(`${key}Changed`);
|
||||
get blue() {
|
||||
return this.state.blue;
|
||||
}
|
||||
|
||||
set blue(blue) {
|
||||
this.wrapRgbSet(() => {
|
||||
super.blue = blue;
|
||||
});
|
||||
}
|
||||
|
||||
static defaultState() {
|
||||
return {
|
||||
red: 0,
|
||||
green: 0,
|
||||
blue: 0,
|
||||
};
|
||||
}
|
||||
|
||||
get green() {
|
||||
return this.state.green;
|
||||
}
|
||||
|
||||
set green(green) {
|
||||
this.wrapRgbSet(() => {
|
||||
super.green = green;
|
||||
});
|
||||
}
|
||||
|
||||
get hue() {
|
||||
return rgb2hsv([this.red, this.green, this.blue])[0];
|
||||
}
|
||||
|
||||
set hue(hue) {
|
||||
this.wrapHsvSet(0, hue);
|
||||
}
|
||||
|
||||
get red() {
|
||||
return this.state.red;
|
||||
}
|
||||
|
||||
set red(red) {
|
||||
this.wrapRgbSet(() => {
|
||||
super.red = red;
|
||||
});
|
||||
}
|
||||
|
||||
get saturation() {
|
||||
return rgb2hsv([this.red, this.green, this.blue])[1];
|
||||
}
|
||||
|
||||
set saturation(saturation) {
|
||||
this.wrapHsvSet(1, saturation);
|
||||
}
|
||||
|
||||
get value() {
|
||||
return rgb2hsv([this.red, this.green, this.blue])[2];
|
||||
}
|
||||
|
||||
set value(value) {
|
||||
this.wrapHsvSet(2, value);
|
||||
}
|
||||
|
||||
wrapHsvSet(i, nv) {
|
||||
const hsv = rgb2hsv([this.red, this.green, this.blue]);
|
||||
const keys = ['hue', 'saturation', 'value'];
|
||||
if (nv !== hsv[i]) {
|
||||
hsv[i] = nv;
|
||||
[this.red, this.green, this.blue] = hsv2rgb(hsv);
|
||||
this.entity.emit(`${keys[i]}Changed`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
wrapRgbSet(fn) {
|
||||
const o = rgb2hsv([this.red, this.green, this.blue]);
|
||||
fn();
|
||||
const n = rgb2hsv([this.red, this.green, this.blue]);
|
||||
['hue', 'saturation', 'value'].forEach((key, i) => {
|
||||
if (n[i] !== o[i]) {
|
||||
this.entity.emit(`${key}Changed`);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load Diff
122
packages/core/.gitignore
vendored
122
packages/core/.gitignore
vendored
|
@ -1,6 +1,116 @@
|
|||
**/*.js
|
||||
**/*.map
|
||||
/assets
|
||||
!/.*
|
||||
!src/**/*.js
|
||||
!/test/**/*.js
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
|
|
@ -1,24 +1,35 @@
|
|||
{
|
||||
"name": "@avocado/core",
|
||||
"version": "2.0.0",
|
||||
"version": "3.0.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.hq.cha0s.io/cha0s/avocado.git",
|
||||
"directory": "packages/core"
|
||||
},
|
||||
"main": "index.js",
|
||||
"author": "cha0s",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "latus-build",
|
||||
"clean": "latus-build clean",
|
||||
"fp": "latus-build forcepublish",
|
||||
"lint": "latus-build lint",
|
||||
"test": "latus-build test"
|
||||
"build": "flecks build",
|
||||
"clean": "flecks clean",
|
||||
"lint": "flecks lint",
|
||||
"postversion": "cp package.json dist",
|
||||
"test": "flecks test"
|
||||
},
|
||||
"files": [
|
||||
"build",
|
||||
"index.js",
|
||||
"index.js.map",
|
||||
"src",
|
||||
"test",
|
||||
"test.js",
|
||||
"test.js.map"
|
||||
],
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"@flecks/core": "^1.3.0",
|
||||
"chai": "4.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@latus/build": "1.x"
|
||||
"@flecks/fleck": "^1.3.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable no-underscore-dangle */
|
||||
export default class TickingPromise extends Promise {
|
||||
|
||||
constructor(executor, ticker) {
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
import {expect} from 'chai';
|
||||
|
||||
it('exists', () => {
|
||||
expect(true).to.be.true;
|
||||
});
|
|
@ -9,7 +9,11 @@ describe('Property', () => {
|
|||
});
|
||||
it('dies if duplicate properties are defined', () => {
|
||||
expect(() => {
|
||||
Property('property')(class {property() {}});
|
||||
Property('property')(class {
|
||||
|
||||
property() {}
|
||||
|
||||
});
|
||||
}).to.throw();
|
||||
});
|
||||
it('accepts initializer', () => {
|
||||
|
@ -18,14 +22,15 @@ describe('Property', () => {
|
|||
initialize() {
|
||||
hasInitialized = this instanceof Class;
|
||||
},
|
||||
})(class {}) {};
|
||||
})(class {}) {}
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const object = new Class();
|
||||
expect(hasInitialized).to.be.true;
|
||||
});
|
||||
it('accepts defaults', () => {
|
||||
class Class extends Property('property', {
|
||||
default: 420,
|
||||
})(class {}) {};
|
||||
})(class {}) {}
|
||||
const object = new Class();
|
||||
expect(object.property).to.equal(420);
|
||||
});
|
||||
|
@ -35,7 +40,7 @@ describe('Property', () => {
|
|||
get() {
|
||||
return 420;
|
||||
},
|
||||
})(class {}) {};
|
||||
})(class {}) {}
|
||||
const object = new Class();
|
||||
expect(object.property).to.equal(420);
|
||||
});
|
||||
|
@ -45,7 +50,7 @@ describe('Property', () => {
|
|||
set(value) {
|
||||
s = value;
|
||||
},
|
||||
})(class {}) {};
|
||||
})(class {}) {}
|
||||
const object = new Class();
|
||||
object.property = 420;
|
||||
expect(s).to.equal(420);
|
||||
|
@ -55,8 +60,12 @@ describe('Property', () => {
|
|||
class Class extends Property('property', {
|
||||
track: true,
|
||||
})(class {}) {
|
||||
emit(type, o, v) {emitted = ('propertyChanged' === type && 420 === v)}
|
||||
};
|
||||
|
||||
emit(type, o, v) {
|
||||
emitted = ('propertyChanged' === type && 420 === v);
|
||||
}
|
||||
|
||||
}
|
||||
const object = new Class();
|
||||
expect(emitted).to.be.false;
|
||||
object.property = 420;
|
||||
|
@ -69,7 +78,7 @@ describe('Property', () => {
|
|||
emitted = ('propertyChanged' === type && 420 === v);
|
||||
},
|
||||
track: true,
|
||||
})(class {}) {};
|
||||
})(class {}) {}
|
||||
const object = new Class();
|
||||
expect(emitted).to.be.false;
|
||||
object.property = 420;
|
||||
|
@ -77,7 +86,7 @@ describe('Property', () => {
|
|||
});
|
||||
it('accepts comparator', () => {
|
||||
let emitted = false;
|
||||
const emit = (type, o, v) => {
|
||||
const emit = (type) => {
|
||||
emitted = ('propertyChanged' === type);
|
||||
};
|
||||
class Class extends Property('property', {
|
||||
|
@ -85,7 +94,7 @@ describe('Property', () => {
|
|||
emit,
|
||||
eq: (l, r) => l[0] === r[0] && l[1] === r[1],
|
||||
track: true,
|
||||
})(class {}) {};
|
||||
})(class {}) {}
|
||||
const object = new Class();
|
||||
expect(emitted).to.be.false;
|
||||
object.property = [0, 0];
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import {assert, expect} from 'chai';
|
||||
import {assert} from 'chai';
|
||||
import TickingPromise from '../src/ticking-promise';
|
||||
|
||||
const createTickingPromise = (duration) => new TickingPromise(
|
||||
() => {},
|
||||
(elapsed, resolve, reject) => {
|
||||
(elapsed, resolve) => {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
duration -= elapsed;
|
||||
if (duration <= 0) {
|
||||
resolve();
|
||||
|
@ -14,7 +15,7 @@ const createTickingPromise = (duration) => new TickingPromise(
|
|||
describe('TickingPromise', () => {
|
||||
it('can behave as a promise', async () => {
|
||||
try {
|
||||
await new TickingPromise((resolve, reject) => {
|
||||
await new TickingPromise((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
@ -40,7 +41,7 @@ describe('TickingPromise', () => {
|
|||
});
|
||||
it('implements a compatible .all', async () => {
|
||||
await TickingPromise.all([
|
||||
new Promise((resolve, reject) => {
|
||||
new Promise((resolve) => {
|
||||
resolve();
|
||||
}),
|
||||
]);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {assert, expect} from 'chai';
|
||||
import {expect} from 'chai';
|
||||
import virtualize from '../src/virtualize';
|
||||
|
||||
const NoMethod = virtualize(['method'], class {});
|
||||
|
|
File diff suppressed because it is too large
Load Diff
122
packages/dialog/.gitignore
vendored
122
packages/dialog/.gitignore
vendored
|
@ -1,6 +1,116 @@
|
|||
**/*.js
|
||||
**/*.map
|
||||
/assets
|
||||
!/.*
|
||||
!src/**/*.js
|
||||
!/test/**/*.js
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
|
|
@ -1,26 +1,33 @@
|
|||
{
|
||||
"name": "@avocado/dialog",
|
||||
"version": "1.0.0",
|
||||
"version": "3.0.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.hq.cha0s.io/cha0s/avocado.git",
|
||||
"directory": "packages/dialog"
|
||||
},
|
||||
"main": "index.js",
|
||||
"author": "cha0s",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "latus-build",
|
||||
"clean": "latus-build clean",
|
||||
"fp": "latus-build forcepublish",
|
||||
"lint": "latus-build lint",
|
||||
"test": "latus-build test"
|
||||
"build": "flecks build",
|
||||
"clean": "flecks clean",
|
||||
"lint": "flecks lint",
|
||||
"postversion": "cp package.json dist",
|
||||
"test": "flecks test"
|
||||
},
|
||||
"files": [
|
||||
"build",
|
||||
"index.js",
|
||||
"index.js.map",
|
||||
"src",
|
||||
"test",
|
||||
"test.js",
|
||||
"test.js.map"
|
||||
],
|
||||
"dependencies": {
|
||||
"@avocado/traits": "^2.0.0",
|
||||
"@latus/core": "^2.0.0",
|
||||
"@latus/socket": "^2.0.0",
|
||||
"@avocado/entity": "^3.0.0",
|
||||
"@flecks/core": "^1.3.0",
|
||||
"lodash.get": "^4.4.2",
|
||||
"lodash.set": "^4.3.2",
|
||||
"remark-mdx": "2.0.0-next.8",
|
||||
|
@ -29,6 +36,6 @@
|
|||
"unist-util-visit-parents": "^3.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@latus/build": "1.x"
|
||||
"@flecks/fleck": "^1.3.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,34 +1,31 @@
|
|||
import {decorateWithLatus, gatherWithLatus} from '@latus/core';
|
||||
import {Flecks, Hooks} from '@flecks/core';
|
||||
|
||||
import dialogFunctions from './dialog-functions';
|
||||
import parse from './parser';
|
||||
import wordize from './wordize';
|
||||
|
||||
export default {
|
||||
hooks: {
|
||||
'@avocado/dialog/functions': dialogFunctions,
|
||||
'@avocado/traits/traits.decorate': decorateWithLatus(
|
||||
require.context('./traits/decorators', false, /\.js$/),
|
||||
[Hooks]: {
|
||||
'@avocado/dialog.functions': dialogFunctions,
|
||||
'@avocado/traits.traits.decorate': (
|
||||
Flecks.decorate(require.context('./traits/decorators', false, /\.js$/))
|
||||
),
|
||||
'@avocado/traits/traits': gatherWithLatus(
|
||||
require.context('./traits', false, /\.js$/),
|
||||
),
|
||||
'@latus/core/starting': (latus) => {
|
||||
const dialogFunctions = latus.invokeReduce('@avocado/dialog/functions');
|
||||
'@avocado/traits.traits': Flecks.provide(require.context('./traits', false, /\.js$/)),
|
||||
'@flecks/core.starting': (flecks) => {
|
||||
const dialogFunctions = flecks.invokeMerge('@avocado/dialog.functions');
|
||||
const resolver = (type) => (dialogFunctions[type] ? dialogFunctions[type] : (i) => i);
|
||||
latus.set('%dialogParser', async (text) => {
|
||||
const {Entity} = latus.get('%resources');
|
||||
flecks.set('$avocado/dialog.parser', async (text) => {
|
||||
const {Entity} = flecks.get('$avocado/resource.resources');
|
||||
const letters = await Promise.all(
|
||||
parse(text, resolver).map((letter) => Entity.load({traits: letter})),
|
||||
parse(text, resolver)
|
||||
.map((letter) => Entity.load({traits: letter})),
|
||||
);
|
||||
return {
|
||||
letters,
|
||||
words: await wordize(letters, latus),
|
||||
words: await wordize(letters, flecks),
|
||||
};
|
||||
});
|
||||
},
|
||||
'@latus/socket/packets': gatherWithLatus(
|
||||
require.context('./packets', false, /\.js$/),
|
||||
),
|
||||
'@flecks/socket.packets': Flecks.provide(require.context('./packets', false, /\.js$/)),
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import {Packet} from '@latus/socket';
|
||||
export default (flecks) => {
|
||||
const {Packet} = flecks.fleck('@flecks/socket');
|
||||
return class OpenDialogPacket extends Packet {
|
||||
|
||||
export default () => class OpenDialogPacket extends Packet {
|
||||
|
||||
static get data() {
|
||||
return {
|
||||
text: 'string',
|
||||
};
|
||||
}
|
||||
static get data() {
|
||||
return {
|
||||
text: 'string',
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export default (Trait, latus) => class DialogInitiator extends Trait {
|
||||
export default (Trait, flecks) => class DialogInitiator extends Trait {
|
||||
|
||||
#open = [];
|
||||
|
||||
|
@ -37,8 +37,8 @@ export default (Trait, latus) => class DialogInitiator extends Trait {
|
|||
...super.methods(),
|
||||
|
||||
openDialog: async (text) => {
|
||||
if ('client' === process.env.SIDE) {
|
||||
const {Entity} = latus.get('%resources');
|
||||
if ('http' === process.env.FLECKS_CORE_BUILD_TARGET) {
|
||||
const {Entity} = flecks.get('$avocado/resource.resources');
|
||||
if (!this.entity.list) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
import {StateProperty, Trait} from '@avocado/traits';
|
||||
import {compose} from '@latus/core';
|
||||
import {compose} from '@flecks/core';
|
||||
|
||||
const decorate = compose(
|
||||
StateProperty('rate'),
|
||||
);
|
||||
export default (flecks) => {
|
||||
const {StateProperty, Trait} = flecks.fleck('@avocado/traits');
|
||||
|
||||
export default () => class DialogText extends decorate(Trait) {
|
||||
const decorate = compose(
|
||||
StateProperty('rate'),
|
||||
);
|
||||
|
||||
static defaultState() {
|
||||
return {
|
||||
rate: 0.1,
|
||||
};
|
||||
}
|
||||
return class DialogText extends decorate(Trait) {
|
||||
|
||||
static defaultState() {
|
||||
return {
|
||||
rate: 0.1,
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,100 +1,101 @@
|
|||
import {Trait} from '@avocado/traits';
|
||||
export default (flecks) => {
|
||||
const {Trait} = flecks.fleck('@avocado/traits');
|
||||
return class Dialog extends Trait {
|
||||
|
||||
export default (latus) => class Dialog extends Trait {
|
||||
#dialog;
|
||||
|
||||
#dialog;
|
||||
#letters = [];
|
||||
|
||||
#letters = [];
|
||||
#nextLetter = 0;
|
||||
|
||||
#nextLetter = 0;
|
||||
#thisLetter = 0;
|
||||
|
||||
#thisLetter = 0;
|
||||
#words = [];
|
||||
|
||||
#words = [];
|
||||
static defaultParams() {
|
||||
return {
|
||||
rate: 0.05,
|
||||
};
|
||||
}
|
||||
|
||||
static defaultParams() {
|
||||
return {
|
||||
rate: 0.05,
|
||||
};
|
||||
}
|
||||
static dependencies() {
|
||||
return [
|
||||
'Textual',
|
||||
'DomNode',
|
||||
];
|
||||
}
|
||||
|
||||
static dependencies() {
|
||||
return [
|
||||
'Textual',
|
||||
'DomNode',
|
||||
];
|
||||
}
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
hooks() {
|
||||
return {
|
||||
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
hooks() {
|
||||
return {
|
||||
visibleAabbs: () => [-64, -64, 64, 64],
|
||||
|
||||
visibleAabbs: () => [-64, -64, 64, 64],
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
async load(json) {
|
||||
await super.load(json);
|
||||
if ('client' === process.env.SIDE) {
|
||||
this.entity.node.className = 'dialog';
|
||||
const {text} = this.entity;
|
||||
if (text) {
|
||||
({
|
||||
letters: this.#letters,
|
||||
words: this.#words,
|
||||
} = await latus.get('%dialogParser')(
|
||||
`<rate frequency={${this.params.rate}}>${text}</rate>`,
|
||||
));
|
||||
if (this.#letters.length > 0) {
|
||||
this.showThisLetter();
|
||||
this.#words.forEach((word) => {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
word.parentNode = this.entity.node;
|
||||
});
|
||||
async load(json) {
|
||||
await super.load(json);
|
||||
if ('http' === process.env.FLECKS_CORE_BUILD_TARGET) {
|
||||
this.entity.node.className = 'dialog';
|
||||
const {text} = this.entity;
|
||||
if (text) {
|
||||
({
|
||||
letters: this.#letters,
|
||||
words: this.#words,
|
||||
} = await flecks.get('$avocado/dialog.parser')(
|
||||
`<rate frequency={${this.params.rate}}>${text}</rate>`,
|
||||
));
|
||||
if (this.#letters.length > 0) {
|
||||
this.showThisLetter();
|
||||
this.#words.forEach((word) => {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
word.parentNode = this.entity.node;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
methods() {
|
||||
return {
|
||||
methods() {
|
||||
return {
|
||||
|
||||
skip: () => {
|
||||
if (this.#nextLetter === Infinity) {
|
||||
this.entity.destroy();
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < this.#letters.length; ++i) {
|
||||
this.#letters[i].opacity = 1;
|
||||
}
|
||||
this.#nextLetter = Infinity;
|
||||
},
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
showThisLetter() {
|
||||
const letter = this.#letters[this.#thisLetter];
|
||||
this.#nextLetter += letter.rate;
|
||||
letter.opacity = 1;
|
||||
}
|
||||
|
||||
tick(elapsed) {
|
||||
if ('client' === process.env.SIDE) {
|
||||
this.#nextLetter -= elapsed;
|
||||
if (this.#nextLetter <= 0) {
|
||||
this.#thisLetter += 1;
|
||||
if (this.#thisLetter >= this.#letters.length) {
|
||||
skip: () => {
|
||||
if (this.#nextLetter === Infinity) {
|
||||
this.entity.destroy();
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < this.#letters.length; ++i) {
|
||||
this.#letters[i].opacity = 1;
|
||||
}
|
||||
this.#nextLetter = Infinity;
|
||||
return;
|
||||
},
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
showThisLetter() {
|
||||
const letter = this.#letters[this.#thisLetter];
|
||||
this.#nextLetter += letter.rate;
|
||||
letter.opacity = 1;
|
||||
}
|
||||
|
||||
tick(elapsed) {
|
||||
if ('http' === process.env.FLECKS_CORE_BUILD_TARGET) {
|
||||
this.#nextLetter -= elapsed;
|
||||
if (this.#nextLetter <= 0) {
|
||||
this.#thisLetter += 1;
|
||||
if (this.#thisLetter >= this.#letters.length) {
|
||||
this.#nextLetter = Infinity;
|
||||
return;
|
||||
}
|
||||
this.showThisLetter();
|
||||
}
|
||||
for (let i = 0; i < this.#words.length; ++i) {
|
||||
this.#words[i].tick(elapsed);
|
||||
}
|
||||
this.showThisLetter();
|
||||
}
|
||||
for (let i = 0; i < this.#words.length; ++i) {
|
||||
this.#words[i].tick(elapsed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const createWord = async (letters, latus) => {
|
||||
const {Entity} = latus.get('%resources');
|
||||
const createWord = async (letters, flecks) => {
|
||||
const {Entity} = flecks.get('$avocado/resource.resources');
|
||||
const word = await Entity.load({
|
||||
traits: {
|
||||
DomNode: {
|
||||
|
@ -27,19 +27,19 @@ const createWord = async (letters, latus) => {
|
|||
return word;
|
||||
};
|
||||
|
||||
export default async (letters, latus) => {
|
||||
export default async (letters, flecks) => {
|
||||
const words = [];
|
||||
let word = [];
|
||||
for (let i = 0; i < letters.length; i++) {
|
||||
const {text} = letters[i];
|
||||
word.push(letters[i]);
|
||||
if (text.match(/[^a-zA-Z0-9_]/)) {
|
||||
words.push(createWord(word, latus));
|
||||
words.push(createWord(word, flecks));
|
||||
word = [];
|
||||
}
|
||||
}
|
||||
if (word.length > 0) {
|
||||
words.push(createWord(word, latus));
|
||||
words.push(createWord(word, flecks));
|
||||
}
|
||||
return Promise.all(words);
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load Diff
124
packages/entity-persea/.gitignore
vendored
124
packages/entity-persea/.gitignore
vendored
|
@ -1,8 +1,116 @@
|
|||
**/*.js
|
||||
**/*.map
|
||||
/assets
|
||||
!/.*
|
||||
!/postcss.config.js
|
||||
!/webpack.config.js
|
||||
!src/**/*.js
|
||||
!/test/**/*.js
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
|
6
packages/entity-persea/build/flecks.yml
Normal file
6
packages/entity-persea/build/flecks.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
'@flecks/core': {}
|
||||
'@flecks/fleck': {}
|
||||
'@flecks/http': {}
|
||||
'@flecks/http/server':
|
||||
build: false
|
||||
'@flecks/react': {}
|
|
@ -1,30 +1,41 @@
|
|||
{
|
||||
"version": "1.0.0",
|
||||
"name": "@avocado/entity-persea",
|
||||
"version": "3.0.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.hq.cha0s.io/cha0s/avocado.git",
|
||||
"directory": "packages/entity-persea"
|
||||
},
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "latus-build",
|
||||
"clean": "latus-build clean",
|
||||
"fp": "latus-build forcepublish",
|
||||
"lint": "latus-build lint",
|
||||
"test": "latus-build test"
|
||||
"build": "flecks build",
|
||||
"clean": "flecks clean",
|
||||
"lint": "flecks lint",
|
||||
"postversion": "cp package.json dist",
|
||||
"test": "flecks test"
|
||||
},
|
||||
"files": [
|
||||
"build",
|
||||
"index.js",
|
||||
"index.js.map",
|
||||
"src",
|
||||
"test",
|
||||
"test.js",
|
||||
"test.js.map"
|
||||
],
|
||||
"dependencies": {
|
||||
"@avocado/graphics": "^2.0.0",
|
||||
"@avocado/math": "^2.0.0",
|
||||
"@avocado/react": "^1.0.0",
|
||||
"@avocado/resource-persea": "^1.0.0",
|
||||
"@latus/react": "^2.0.0",
|
||||
"@avocado/graphics": "^3.0.0",
|
||||
"@avocado/math": "^3.0.0",
|
||||
"@avocado/react": "^3.0.0",
|
||||
"@avocado/resource-persea": "^3.0.0",
|
||||
"@flecks/core": "^1.3.0",
|
||||
"@flecks/react": "^1.3.0",
|
||||
"lodash.difference": "^4.5.0",
|
||||
"react-autosuggest": "^10.1.0"
|
||||
"react-autosuggest": "^10.1.0",
|
||||
"react-tabs": "^4.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@latus/build": "1.x"
|
||||
},
|
||||
"name": "@avocado/entity-persea"
|
||||
"@flecks/fleck": "^1.3.0",
|
||||
"@flecks/http": "^1.3.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ import {
|
|||
TabList,
|
||||
TabPanel,
|
||||
useEffect,
|
||||
useLatus,
|
||||
useFlecks,
|
||||
useParams,
|
||||
useState,
|
||||
} from '@latus/react';
|
||||
} from '@flecks/react';
|
||||
|
||||
import Traits from './traits';
|
||||
import View from './view';
|
||||
|
@ -22,9 +22,9 @@ const EntityComponent = ({
|
|||
resource,
|
||||
path,
|
||||
}) => {
|
||||
const latus = useLatus();
|
||||
const flecks = useFlecks();
|
||||
const {uri} = useParams();
|
||||
const {Entity, EntityList} = latus.get('%resources');
|
||||
const {Entity, EntityList} = flecks.get('$avocado/resource.resources');
|
||||
const [entity, setEntity] = useState();
|
||||
useEffect(() => {
|
||||
setEntity();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@import '~@latus/react/tabs.scss';
|
||||
@import '~react-tabs/style/react-tabs.scss';
|
||||
|
||||
.entity-renderer {
|
||||
height: 100%;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {JsonController} from '@avocado/resource-persea';
|
||||
|
||||
export default (buffer, latus) => {
|
||||
const {Entity} = latus.get('%resources');
|
||||
export default (buffer, flecks) => {
|
||||
const {Entity} = flecks.get('$avocado/resource.resources');
|
||||
const json = Entity.withDefaults(JsonController.fromBuffer(buffer));
|
||||
return {
|
||||
...json,
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
React,
|
||||
useEffect,
|
||||
useState,
|
||||
} from '@latus/react';
|
||||
} from '@flecks/react';
|
||||
|
||||
import {Stage} from '@avocado/graphics';
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {JsonController} from '@avocado/resource-persea';
|
||||
|
||||
export default (resource, latus) => {
|
||||
const {Entity} = latus.get('%resources');
|
||||
export default (resource, flecks) => {
|
||||
const {Entity} = flecks.get('$avocado/resource.resources');
|
||||
const json = Entity.withoutDefaults(resource);
|
||||
return JsonController.toBuffer({
|
||||
...json,
|
||||
|
|
|
@ -11,10 +11,10 @@ import {
|
|||
Tabs,
|
||||
TabList,
|
||||
TabPanel,
|
||||
useLatus,
|
||||
useFlecks,
|
||||
useRef,
|
||||
useState,
|
||||
} from '@latus/react';
|
||||
} from '@flecks/react';
|
||||
import difference from 'lodash.difference';
|
||||
|
||||
import Suggest from './suggest';
|
||||
|
@ -37,7 +37,7 @@ const Traits = ({
|
|||
}) => {
|
||||
const patch = useJsonPatcher();
|
||||
const buttonRef = useRef();
|
||||
const latus = useLatus();
|
||||
const flecks = useFlecks();
|
||||
const [isSelecting, setIsSelecting] = useState(false);
|
||||
const types = Object.keys(json).sort((l, r) => (l < r ? -1 : 1));
|
||||
const tabs = types.map((type) => (
|
||||
|
@ -58,14 +58,14 @@ const Traits = ({
|
|||
</button>
|
||||
</Tab>
|
||||
));
|
||||
const Traits = latus.get('%traits');
|
||||
const Traits = flecks.get('$avocado/traits.traits');
|
||||
const suggestible = difference(
|
||||
Object.entries(Traits)
|
||||
.filter(([key]) => !Number.isInteger(parseInt(key, 10)))
|
||||
.map(([, {type}]) => type),
|
||||
types,
|
||||
);
|
||||
const Components = latus.get('%trait-components');
|
||||
const Components = flecks.get('$avocado/traits-persea.components');
|
||||
const tabPanels = types.map((type) => {
|
||||
const Component = Components[type] || JsonTraitComponent;
|
||||
return (
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
} from '@latus/react';
|
||||
} from '@flecks/react';
|
||||
import Autosuggest from 'react-autosuggest';
|
||||
|
||||
const Suggest = ({
|
||||
|
|
|
@ -3,7 +3,7 @@ import './index.scss';
|
|||
import {
|
||||
PropTypes,
|
||||
React,
|
||||
} from '@latus/react';
|
||||
} from '@flecks/react';
|
||||
|
||||
import EntityStage from '../stage';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {gatherComponents} from '@latus/react';
|
||||
import {Flecks, Hooks} from '@flecks/react';
|
||||
|
||||
import EntityController from './controllers/entity';
|
||||
|
||||
|
@ -7,12 +7,13 @@ export {
|
|||
};
|
||||
|
||||
export default {
|
||||
hooks: {
|
||||
'@avocado/resource-persea/controllers': () => [
|
||||
[Hooks]: {
|
||||
'@avocado/resource-persea.controllers': () => [
|
||||
EntityController,
|
||||
],
|
||||
'@avocado/traits-persea/components': gatherComponents(
|
||||
'@avocado/traits-persea.components': Flecks.provide(
|
||||
require.context('./traits', false, /\.jsx$/),
|
||||
{invoke: false},
|
||||
),
|
||||
},
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
hot,
|
||||
PropTypes,
|
||||
React,
|
||||
} from '@latus/react';
|
||||
} from '@flecks/react';
|
||||
import {useJsonPatcher} from '@avocado/resource-persea';
|
||||
|
||||
const Alive = ({
|
||||
|
@ -34,6 +34,7 @@ const Alive = ({
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
|
||||
<label>
|
||||
<div>Life</div>
|
||||
<div className="alive__life">
|
||||
|
|
|
@ -7,13 +7,14 @@ import {
|
|||
hot,
|
||||
PropTypes,
|
||||
React,
|
||||
} from '@latus/react';
|
||||
} from '@flecks/react';
|
||||
import {useJsonPatcher} from '@avocado/resource-persea';
|
||||
|
||||
const Directional = ({json, path}) => {
|
||||
const patch = useJsonPatcher();
|
||||
return (
|
||||
<div className="directional">
|
||||
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
|
||||
<label>
|
||||
Direction count
|
||||
<select
|
||||
|
@ -28,6 +29,7 @@ const Directional = ({json, path}) => {
|
|||
<option value={8}>8-direction</option>
|
||||
</select>
|
||||
</label>
|
||||
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
|
||||
<label>
|
||||
Track movement
|
||||
{json.params.trackMovement ? '' : '?'}
|
||||
|
@ -37,6 +39,7 @@ const Directional = ({json, path}) => {
|
|||
type="checkbox"
|
||||
/>
|
||||
</label>
|
||||
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
|
||||
<label>
|
||||
Direction
|
||||
<Number
|
||||
|
|
File diff suppressed because it is too large
Load Diff
122
packages/entity/.gitignore
vendored
122
packages/entity/.gitignore
vendored
|
@ -1,6 +1,116 @@
|
|||
**/*.js
|
||||
**/*.map
|
||||
/assets
|
||||
!/.*
|
||||
!src/**/*.js
|
||||
!/test/**/*.js
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
|
|
@ -1,37 +1,45 @@
|
|||
{
|
||||
"name": "@avocado/entity",
|
||||
"version": "2.0.0",
|
||||
"version": "3.0.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.hq.cha0s.io/cha0s/avocado.git",
|
||||
"directory": "packages/entity"
|
||||
},
|
||||
"main": "index.js",
|
||||
"author": "cha0s",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "latus-build",
|
||||
"clean": "latus-build clean",
|
||||
"fp": "latus-build forcepublish",
|
||||
"lint": "latus-build lint",
|
||||
"test": "latus-build test"
|
||||
"build": "flecks build",
|
||||
"clean": "flecks clean",
|
||||
"lint": "flecks lint",
|
||||
"postversion": "cp package.json dist",
|
||||
"test": "flecks test"
|
||||
},
|
||||
"files": [
|
||||
"build",
|
||||
"index.js",
|
||||
"index.js.map",
|
||||
"src",
|
||||
"test",
|
||||
"test.js",
|
||||
"test.js.map"
|
||||
],
|
||||
"dependencies": {
|
||||
"@avocado/behavior": "2.0.0",
|
||||
"@avocado/core": "2.0.0",
|
||||
"@avocado/graphics": "^2.0.0",
|
||||
"@avocado/math": "2.0.0",
|
||||
"@avocado/resource": "2.0.0",
|
||||
"@avocado/s13n": "2.0.0",
|
||||
"@avocado/traits": "^2.0.0",
|
||||
"@latus/core": "2.0.0",
|
||||
"@latus/socket": "2.0.0",
|
||||
"@avocado/behavior": "^3.0.0",
|
||||
"@avocado/core": "^3.0.0",
|
||||
"@avocado/graphics": "^3.0.0",
|
||||
"@avocado/math": "^3.0.0",
|
||||
"@avocado/resource": "^3.0.0",
|
||||
"@avocado/s13n": "^3.0.0",
|
||||
"@avocado/traits": "^3.0.0",
|
||||
"@flecks/core": "^1.3.0",
|
||||
"@flecks/socket": "^1.3.0",
|
||||
"debug": "4.3.1",
|
||||
"deepmerge": "^4.2.2",
|
||||
"lodash.without": "^4.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@latus/build": "1.x"
|
||||
"@flecks/fleck": "^1.3.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export default async (latus) => {
|
||||
const {Entity} = latus.get('%resources');
|
||||
const Traits = latus.get('%traits');
|
||||
export default async (flecks) => {
|
||||
const {Entity} = flecks.get('$avocado/resource.resources');
|
||||
const Traits = flecks.get('$avocado/traits.traits');
|
||||
const AllTraits = Object.fromEntries(
|
||||
Object.entries(Traits)
|
||||
.filter(([key]) => !Number.isInteger(parseInt(key, 10))),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {gatherWithLatus} from '@latus/core';
|
||||
import {Flecks, Hooks} from '@flecks/core';
|
||||
|
||||
import hotEntities from './hot-entities';
|
||||
|
||||
|
@ -6,12 +6,10 @@ export {default as EntityListView} from './entity-list-view';
|
|||
export {default as fullEntity} from './full-entity';
|
||||
|
||||
export default {
|
||||
hooks: {
|
||||
'@avocado/resource/resources': gatherWithLatus(
|
||||
require.context('./resources', false, /\.js$/),
|
||||
),
|
||||
'@latus/core/gathered/hmr': (Class, hook) => {
|
||||
if ('@avocado/traits/traits' === hook) {
|
||||
[Hooks]: {
|
||||
'@avocado/resource.resources': Flecks.provide(require.context('./resources', false, /\.js$/)),
|
||||
'@flecks/core.hmr.gathered': (Class, hook) => {
|
||||
if ('@avocado/traits.traits' === hook) {
|
||||
const {type} = Class;
|
||||
const it = hotEntities.values();
|
||||
for (let current = it.next(); current.done !== true; current = it.next()) {
|
||||
|
@ -27,11 +25,7 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
'@avocado/traits/traits': gatherWithLatus(
|
||||
require.context('./traits', false, /\.js$/),
|
||||
),
|
||||
'@latus/socket/packets': gatherWithLatus(
|
||||
require.context('./packets', false, /\.js$/),
|
||||
),
|
||||
'@avocado/traits.traits': Flecks.provide(require.context('./traits', false, /\.js$/)),
|
||||
'@flecks/socket.packets': Flecks.provide(require.context('./packets', false, /\.js$/)),
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
import {Packet} from '@latus/socket';
|
||||
import {Packet} from '@flecks/socket';
|
||||
|
||||
export default () => class DiedPacket extends Packet {};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {Packet} from '@latus/socket';
|
||||
import {Packet} from '@flecks/socket';
|
||||
|
||||
export default () => class TraitUpdateAlivePacket extends Packet {
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {Packet} from '@latus/socket';
|
||||
import {Packet} from '@flecks/socket';
|
||||
|
||||
export default () => class TraitUpdateDirectionalDirectionPacket extends Packet {
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {Packet} from '@latus/socket';
|
||||
import {Packet} from '@flecks/socket';
|
||||
|
||||
export default () => class TraitUpdateMobilePacket extends Packet {
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {Vector} from '@avocado/math';
|
||||
import {compose} from '@latus/core';
|
||||
import {Packet} from '@latus/socket';
|
||||
import {compose} from '@flecks/core';
|
||||
import {Packet} from '@flecks/socket';
|
||||
|
||||
const decorate = compose(
|
||||
Vector.Packer(),
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import {compose, EventEmitter} from '@latus/core';
|
||||
import {compose, EventEmitter} from '@flecks/core';
|
||||
import {QuadTree, Rectangle} from '@avocado/math';
|
||||
import {JsonResource} from '@avocado/resource';
|
||||
import {Synchronized} from '@avocado/s13n';
|
||||
|
||||
export default (latus) => {
|
||||
export default (flecks) => {
|
||||
const decorate = compose(
|
||||
EventEmitter,
|
||||
Synchronized(latus),
|
||||
Synchronized(flecks),
|
||||
);
|
||||
return class EntityList extends decorate(JsonResource) {
|
||||
|
||||
|
@ -26,7 +26,7 @@ export default (latus) => {
|
|||
await super.acceptPacket(packet);
|
||||
const {s13nType} = packet;
|
||||
if ('create' === s13nType) {
|
||||
const {Entity} = latus.get('%resources');
|
||||
const {Entity} = flecks.get('$avocado/resource.resources');
|
||||
const {id} = packet.data.synchronized;
|
||||
const entity = this.synchronized(Entity.resourceId, id);
|
||||
if (entity) {
|
||||
|
@ -51,7 +51,7 @@ export default (latus) => {
|
|||
entity.emit('addedToList');
|
||||
entity.once('destroying', () => this.onEntityDestroying(entity));
|
||||
this.emit('entityAdded', entity);
|
||||
if ('client' !== process.env.SIDE) {
|
||||
if ('http' !== process.env.FLECKS_CORE_BUILD_TARGET) {
|
||||
this.#informedEntities.set(entity, []);
|
||||
}
|
||||
this.startSynchronizing(entity);
|
||||
|
@ -86,7 +86,7 @@ export default (latus) => {
|
|||
return;
|
||||
}
|
||||
await this.destroyEntities();
|
||||
const {Entity} = latus.get('%resources');
|
||||
const {Entity} = flecks.get('$avocado/resource.resources');
|
||||
const entityInstances = await Promise.all(json.map((entity) => Entity.load(entity)));
|
||||
for (let i = 0; i < entityInstances.length; i++) {
|
||||
this.addEntity(entityInstances[i]);
|
||||
|
@ -106,7 +106,7 @@ export default (latus) => {
|
|||
|
||||
packetsFor(informed) {
|
||||
const packets = [];
|
||||
const {Entity} = latus.get('%resources');
|
||||
const {Entity} = flecks.get('$avocado/resource.resources');
|
||||
// Visible entities.
|
||||
const {areaToInform} = informed;
|
||||
const previousVisibleEntities = this.#informedEntities.get(informed);
|
||||
|
@ -158,7 +158,7 @@ export default (latus) => {
|
|||
return;
|
||||
}
|
||||
this.stopSynchronizing(entity);
|
||||
if ('client' !== process.env.SIDE) {
|
||||
if ('http' !== process.env.FLECKS_CORE_BUILD_TARGET) {
|
||||
this.#informedEntities.delete(entity);
|
||||
}
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
|
|
|
@ -7,7 +7,7 @@ import {
|
|||
TickingPromise,
|
||||
} from '@avocado/core';
|
||||
import {Synchronized} from '@avocado/s13n';
|
||||
import {compose, EventEmitter} from '@latus/core';
|
||||
import {compose, EventEmitter} from '@flecks/core';
|
||||
import {JsonResource} from '@avocado/resource';
|
||||
|
||||
import {defineTraitAccessors, enumerateTraitAccessorKeys} from '../accessors';
|
||||
|
@ -15,12 +15,12 @@ import hotEntities from '../hot-entities';
|
|||
|
||||
const debug = D('@avocado/entity');
|
||||
|
||||
let numericUid = 'client' !== process.env.SIDE ? 1 : 1000000000;
|
||||
let numericUid = 'http' !== process.env.FLECKS_CORE_BUILD_TARGET ? 1 : 1000000000;
|
||||
|
||||
export default (latus) => {
|
||||
export default (flecks) => {
|
||||
const decorate = compose(
|
||||
EventEmitter,
|
||||
Synchronized(latus),
|
||||
Synchronized(flecks),
|
||||
);
|
||||
return class Entity extends decorate(JsonResource) {
|
||||
|
||||
|
@ -75,8 +75,8 @@ export default (latus) => {
|
|||
});
|
||||
}
|
||||
|
||||
async _addTrait(type, json = {}) {
|
||||
const {[type]: Trait} = latus.get('%traits');
|
||||
async $$addTrait(type, json = {}) {
|
||||
const {[type]: Trait} = flecks.get('$avocado/traits.traits');
|
||||
if (!Trait) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`Tried to add trait "${type}" which isn't registered!`);
|
||||
|
@ -152,7 +152,7 @@ export default (latus) => {
|
|||
}
|
||||
|
||||
async addTraits(traits) {
|
||||
const Traits = latus.get('%traits');
|
||||
const Traits = flecks.get('$avocado/traits.traits');
|
||||
const reorganized = {};
|
||||
const add = (type) => {
|
||||
const deps = Traits[type]?.dependencies() || [];
|
||||
|
@ -173,7 +173,7 @@ export default (latus) => {
|
|||
for (let i = 0; i < entries.length; i++) {
|
||||
const [type, json] = entries[i];
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
instances[type] = await this._addTrait(type, json);
|
||||
instances[type] = await this.$$addTrait(type, json);
|
||||
}
|
||||
return instances;
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ export default (latus) => {
|
|||
}
|
||||
|
||||
createContext(locals = {}) {
|
||||
const {Script} = latus.get('%resources');
|
||||
const {Script} = flecks.get('$avocado/resource.resources');
|
||||
return Script.createContext({
|
||||
...this.contextOrDefault,
|
||||
...locals,
|
||||
|
@ -321,7 +321,7 @@ export default (latus) => {
|
|||
const implementation = this.#hooks[hook].find(({type: hookType}) => hookType === type);
|
||||
this.#hooks[hook].splice(this.#hooks[hook].indexOf(implementation), 1);
|
||||
}
|
||||
const {[type]: Trait} = latus.get('%traits');
|
||||
const {[type]: Trait} = flecks.get('$avocado/traits.traits');
|
||||
const properties = enumerateTraitAccessorKeys(Trait.prototype);
|
||||
for (let i = 0; i < properties.length; ++i) {
|
||||
const property = properties[i];
|
||||
|
@ -416,7 +416,7 @@ export default (latus) => {
|
|||
}
|
||||
|
||||
static withDefaults(json = {}) {
|
||||
const Traits = latus.get('%traits');
|
||||
const Traits = flecks.get('$avocado/traits.traits');
|
||||
return {
|
||||
...json,
|
||||
traits: Object.entries(json.traits)
|
||||
|
@ -430,7 +430,7 @@ export default (latus) => {
|
|||
}
|
||||
|
||||
static withoutDefaults(json) {
|
||||
const Traits = latus.get('%traits');
|
||||
const Traits = flecks.get('$avocado/traits.traits');
|
||||
const without = {
|
||||
...json,
|
||||
traits: Object.entries(json.traits)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {TickingPromise} from '@avocado/core';
|
||||
import {StateProperty, Trait} from '@avocado/traits';
|
||||
import {compose} from '@latus/core';
|
||||
import {compose} from '@flecks/core';
|
||||
|
||||
const decorate = compose(
|
||||
StateProperty('life', {
|
||||
|
@ -11,7 +11,7 @@ const decorate = compose(
|
|||
}),
|
||||
);
|
||||
|
||||
export default (latus) => class Alive extends decorate(Trait) {
|
||||
export default (flecks) => class Alive extends decorate(Trait) {
|
||||
|
||||
#deathCheck;
|
||||
|
||||
|
@ -42,7 +42,7 @@ export default (latus) => class Alive extends decorate(Trait) {
|
|||
static defaultParams() {
|
||||
return {
|
||||
deathCheck: 'return entity.life <= 0',
|
||||
deathScript: `if ('client' === SIDE) {
|
||||
deathScript: `if ('http' === FLECKS_CORE_BUILD_TARGET) {
|
||||
await TickingPromise.all([
|
||||
entity.playSound("deathSound"),
|
||||
entity.transition(
|
||||
|
@ -68,7 +68,7 @@ export default (latus) => class Alive extends decorate(Trait) {
|
|||
|
||||
async die() {
|
||||
this.entity.emit('startedDying');
|
||||
const {Script} = latus.get('%resources');
|
||||
const {Script} = flecks.get('$avocado/resource.resources');
|
||||
const deathScript = await Script.load(this.params.deathScript, this.entity.contextOrDefault);
|
||||
await this.entity.addTickingPromise(deathScript.tickingPromise());
|
||||
const died = this.entity.invokeHookFlat('died');
|
||||
|
@ -117,7 +117,7 @@ export default (latus) => class Alive extends decorate(Trait) {
|
|||
|
||||
async load(json) {
|
||||
await super.load(json);
|
||||
const {Script} = latus.get('%resources');
|
||||
const {Script} = flecks.get('$avocado/resource.resources');
|
||||
this.#deathCheck = await Script.load(this.params.deathCheck, this.entity.contextOrDefault);
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ export default (latus) => class Alive extends decorate(Trait) {
|
|||
}
|
||||
|
||||
tick() {
|
||||
if ('client' !== process.env.SIDE) {
|
||||
if ('http' !== process.env.FLECKS_CORE_BUILD_TARGET) {
|
||||
if (!this.#isDying) {
|
||||
this.#deathCheck.evaluate(({value: died}) => {
|
||||
if (died) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {randomNumber, Vector} from '@avocado/math';
|
||||
import {StateProperty, Trait} from '@avocado/traits';
|
||||
import {compose} from '@latus/core';
|
||||
import {compose} from '@flecks/core';
|
||||
|
||||
const decorate = compose(
|
||||
StateProperty('direction', {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {Vector} from '@avocado/math';
|
||||
import {StateProperty, Trait} from '@avocado/traits';
|
||||
import {compose} from '@latus/core';
|
||||
import {compose} from '@flecks/core';
|
||||
|
||||
const decorate = compose(
|
||||
StateProperty('parentNode', {
|
||||
|
@ -90,7 +90,7 @@ export default () => class DomNode extends decorate(Trait) {
|
|||
|
||||
async load(json) {
|
||||
await super.load(json);
|
||||
if ('client' === process.env.SIDE) {
|
||||
if ('http' === process.env.FLECKS_CORE_BUILD_TARGET) {
|
||||
this.entity.node = window.document.createElement('entity');
|
||||
Object.entries(this.params.style).forEach(([key, value]) => {
|
||||
this.entity.node.style[key] = value;
|
||||
|
@ -100,7 +100,7 @@ export default () => class DomNode extends decorate(Trait) {
|
|||
}
|
||||
|
||||
tick() {
|
||||
if ('client' === process.env.SIDE && this.#scheduledRuleApplication) {
|
||||
if ('http' === process.env.FLECKS_CORE_BUILD_TARGET && this.#scheduledRuleApplication) {
|
||||
this.#scheduledRuleApplication = false;
|
||||
this.applyStyleRules();
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ export default () => class DomText extends Trait {
|
|||
|
||||
constructor() {
|
||||
super();
|
||||
if ('client' === process.env.SIDE) {
|
||||
if ('http' === process.env.FLECKS_CORE_BUILD_TARGET) {
|
||||
this.#text = window.document.createElement('span');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {TickingPromise} from '@avocado/core';
|
||||
import {Vector} from '@avocado/math';
|
||||
import {StateProperty, Trait} from '@avocado/traits';
|
||||
import {compose, EventEmitter} from '@latus/core';
|
||||
import {compose, EventEmitter} from '@flecks/core';
|
||||
|
||||
const decorate = compose(
|
||||
EventEmitter,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {StateProperty, Trait} from '@avocado/traits';
|
||||
import {compose} from '@latus/core';
|
||||
import {compose} from '@flecks/core';
|
||||
|
||||
const decorate = compose(
|
||||
StateProperty('name'),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {Trait} from '@avocado/traits';
|
||||
import {compose} from '@latus/core';
|
||||
import {compose} from '@flecks/core';
|
||||
|
||||
const decorate = compose(
|
||||
);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {Vector} from '@avocado/math';
|
||||
import {Trait} from '@avocado/traits';
|
||||
import {compose, EventEmitter} from '@latus/core';
|
||||
import {compose, EventEmitter} from '@flecks/core';
|
||||
|
||||
const decorate = compose(
|
||||
EventEmitter,
|
||||
|
@ -88,7 +88,7 @@ export default () => class Positioned extends decorate(Trait) {
|
|||
this.trackedPosition = [x, y];
|
||||
this.entity.position[0] = x;
|
||||
this.entity.position[1] = y;
|
||||
if ('client' === process.env.SIDE) {
|
||||
if ('http' === process.env.FLECKS_CORE_BUILD_TARGET) {
|
||||
this.serverPosition = this.trackedPosition;
|
||||
this.serverPositionDirty = false;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ export default () => class Positioned extends decorate(Trait) {
|
|||
// eslint-disable-next-line camelcase
|
||||
onTrackedPositionChanged(oldPosition, newPosition) {
|
||||
[this.entity.position[0], this.entity.position[1]] = newPosition;
|
||||
if ('client' !== process.env.SIDE) {
|
||||
if ('http' !== process.env.FLECKS_CORE_BUILD_TARGET) {
|
||||
[this.state.x, this.state.y] = newPosition;
|
||||
this.markAsDirty();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {compose} from '@latus/core';
|
||||
import {compose} from '@flecks/core';
|
||||
import {StateProperty, Trait} from '@avocado/traits';
|
||||
import merge from 'deepmerge';
|
||||
|
||||
|
@ -9,7 +9,7 @@ const decorate = compose(
|
|||
StateProperty('maxSpawns'),
|
||||
);
|
||||
|
||||
export default (latus) => class Spawner extends decorate(Trait) {
|
||||
export default (flecks) => class Spawner extends decorate(Trait) {
|
||||
|
||||
#children;
|
||||
|
||||
|
@ -248,7 +248,7 @@ export default (latus) => class Spawner extends decorate(Trait) {
|
|||
const childIndex = this.#children.length;
|
||||
this.#children.push(null);
|
||||
const list = this.destinationEntityList();
|
||||
const {Entity} = latus.get('%resources');
|
||||
const {Entity} = flecks.get('$avocado/resource.resources');
|
||||
const child = await Entity.load(json);
|
||||
this.#children[childIndex] = child;
|
||||
// Listen for destroy event.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {Property} from '@avocado/core';
|
||||
import {Trait} from '@avocado/traits';
|
||||
import {compose} from '@latus/core';
|
||||
import {compose} from '@flecks/core';
|
||||
|
||||
const decorate = compose(
|
||||
Property('text', {
|
||||
|
|
|
@ -1,142 +1,142 @@
|
|||
import {
|
||||
buildCondition,
|
||||
buildExpression,
|
||||
buildInvoke,
|
||||
} from '@avocado/behavior';
|
||||
import {Latus} from '@latus/core';
|
||||
import {normalize} from '@latus/socket';
|
||||
import {expect} from 'chai';
|
||||
// import {
|
||||
// buildCondition,
|
||||
// buildExpression,
|
||||
// buildInvoke,
|
||||
// } from '@avocado/behavior';
|
||||
// import {Flecks} from '@flecks/core';
|
||||
// import {normalize} from '@flecks/socket';
|
||||
// import {expect} from 'chai';
|
||||
|
||||
let latus;
|
||||
let Entity;
|
||||
beforeEach(async () => {
|
||||
latus = Latus.mock({
|
||||
'@avocado/behavior': require('@avocado/behavior'),
|
||||
'@avocado/entity': require('../src'),
|
||||
'@avocado/resource': require('@avocado/resource'),
|
||||
'@avocado/traits': require('@avocado/traits'),
|
||||
'@latus/socket': require('@latus/socket'),
|
||||
});
|
||||
await Promise.all(latus.invokeFlat('@latus/core/starting'));
|
||||
({Entity} = latus.get('%resources'));
|
||||
});
|
||||
describe('Alive', () => {
|
||||
let entity;
|
||||
beforeEach(async () => {
|
||||
entity = await Entity.load({
|
||||
traits: {
|
||||
Alive: {},
|
||||
},
|
||||
});
|
||||
});
|
||||
it('exists', async () => {
|
||||
expect(entity.is('Alive')).to.be.true;
|
||||
});
|
||||
if ('client' !== process.env.SIDE) {
|
||||
it('can die', async () => {
|
||||
let isDying = false;
|
||||
entity.once('startedDying', () => {
|
||||
isDying = true;
|
||||
});
|
||||
entity.life = 0;
|
||||
entity.tick(0);
|
||||
expect(isDying).to.be.true;
|
||||
});
|
||||
}
|
||||
it('clamps life', async () => {
|
||||
entity.life = 120;
|
||||
expect(entity.life).to.equal(100);
|
||||
entity.maxLife = 50;
|
||||
expect(entity.life).to.equal(50);
|
||||
});
|
||||
if ('client' !== process.env.SIDE) {
|
||||
it('can have a custom death condition', async () => {
|
||||
const entity = await Entity.load({
|
||||
traits: {
|
||||
Alive: {
|
||||
params: {
|
||||
deathCondition: buildCondition('<=', [
|
||||
buildExpression(['entity', 'life']),
|
||||
10,
|
||||
]),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
let isDying = false;
|
||||
entity.on('startedDying', () => {
|
||||
isDying = true;
|
||||
});
|
||||
entity.tick(0);
|
||||
expect(isDying).to.be.false;
|
||||
entity.life = 10;
|
||||
entity.tick(0);
|
||||
expect(isDying).to.be.true;
|
||||
});
|
||||
}
|
||||
it('runs actions on death', async () => {
|
||||
let didActions;
|
||||
const entity = await Entity.load({
|
||||
traits: {
|
||||
Alive: {
|
||||
params: {
|
||||
deathActions: {
|
||||
type: 'expressions',
|
||||
expressions: [
|
||||
buildInvoke(['entity', 'ded']),
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
entity.ded = () => {
|
||||
didActions = true;
|
||||
};
|
||||
const handle = setInterval(() => {
|
||||
entity.tick();
|
||||
}, 16.66);
|
||||
await entity.die();
|
||||
clearInterval(handle);
|
||||
expect(didActions).to.be.true;
|
||||
});
|
||||
describe('Packets', () => {
|
||||
let entity2;
|
||||
beforeEach(async () => {
|
||||
entity2 = await Entity.load({
|
||||
traits: {
|
||||
Alive: {},
|
||||
},
|
||||
});
|
||||
});
|
||||
it('generates and accepts life packets', async () => {
|
||||
entity.life = 80;
|
||||
entity.maxLife = 90;
|
||||
const packets = entity.trait('Alive').packetsFor();
|
||||
expect(packets).to.have.lengthOf(1);
|
||||
expect(packets[0][0]).to.equal('TraitUpdateAlive');
|
||||
expect(packets[0][1]).to.deep.equal({life: 80, maxLife: 90});
|
||||
entity2.trait('Alive').acceptPacket(normalize(latus, packets[0]));
|
||||
expect(entity2.life).to.equal(80);
|
||||
expect(entity2.maxLife).to.equal(90);
|
||||
});
|
||||
if ('client' !== process.env.SIDE) {
|
||||
it('generates and accepts death packets', async () => {
|
||||
entity.life = 0;
|
||||
entity.tick();
|
||||
const packets = entity.trait('Alive').packetsFor();
|
||||
expect(packets).to.have.lengthOf(2);
|
||||
expect(packets[0][0]).to.equal('Died');
|
||||
expect(packets[1][0]).to.equal('TraitUpdateAlive');
|
||||
expect(packets[1][1]).to.deep.equal({life: 0, maxLife: 100});
|
||||
const promise = new Promise((resolve) => {
|
||||
entity2.once('startedDying', resolve);
|
||||
});
|
||||
entity2.trait('Alive').acceptPacket(normalize(latus, packets[0]));
|
||||
entity2.trait('Alive').acceptPacket(normalize(latus, packets[1]));
|
||||
expect(entity2.life).to.equal(0);
|
||||
return promise;
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
// let flecks;
|
||||
// let Entity;
|
||||
// beforeEach(async () => {
|
||||
// flecks = Flecks.mock({
|
||||
// '@avocado/behavior': require('@avocado/behavior'),
|
||||
// '@avocado/entity': require('../src'),
|
||||
// '@avocado/resource': require('@avocado/resource'),
|
||||
// '@avocado/traits': require('@avocado/traits'),
|
||||
// '@flecks/socket': require('@flecks/socket'),
|
||||
// });
|
||||
// await Promise.all(flecks.invokeFlat('@flecks/core/starting'));
|
||||
// ({Entity} = flecks.get('$avocado/resource.resources'));
|
||||
// });
|
||||
// describe('Alive', () => {
|
||||
// let entity;
|
||||
// beforeEach(async () => {
|
||||
// entity = await Entity.load({
|
||||
// traits: {
|
||||
// Alive: {},
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
// it('exists', async () => {
|
||||
// expect(entity.is('Alive')).to.be.true;
|
||||
// });
|
||||
// if ('http' !== process.env.FLECKS_CORE_BUILD_TARGET) {
|
||||
// it('can die', async () => {
|
||||
// let isDying = false;
|
||||
// entity.once('startedDying', () => {
|
||||
// isDying = true;
|
||||
// });
|
||||
// entity.life = 0;
|
||||
// entity.tick(0);
|
||||
// expect(isDying).to.be.true;
|
||||
// });
|
||||
// }
|
||||
// it('clamps life', async () => {
|
||||
// entity.life = 120;
|
||||
// expect(entity.life).to.equal(100);
|
||||
// entity.maxLife = 50;
|
||||
// expect(entity.life).to.equal(50);
|
||||
// });
|
||||
// if ('http' !== process.env.FLECKS_CORE_BUILD_TARGET) {
|
||||
// it('can have a custom death condition', async () => {
|
||||
// const entity = await Entity.load({
|
||||
// traits: {
|
||||
// Alive: {
|
||||
// params: {
|
||||
// deathCondition: buildCondition('<=', [
|
||||
// buildExpression(['entity', 'life']),
|
||||
// 10,
|
||||
// ]),
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// let isDying = false;
|
||||
// entity.on('startedDying', () => {
|
||||
// isDying = true;
|
||||
// });
|
||||
// entity.tick(0);
|
||||
// expect(isDying).to.be.false;
|
||||
// entity.life = 10;
|
||||
// entity.tick(0);
|
||||
// expect(isDying).to.be.true;
|
||||
// });
|
||||
// }
|
||||
// it('runs actions on death', async () => {
|
||||
// let didActions;
|
||||
// const entity = await Entity.load({
|
||||
// traits: {
|
||||
// Alive: {
|
||||
// params: {
|
||||
// deathActions: {
|
||||
// type: 'expressions',
|
||||
// expressions: [
|
||||
// buildInvoke(['entity', 'ded']),
|
||||
// ],
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// entity.ded = () => {
|
||||
// didActions = true;
|
||||
// };
|
||||
// const handle = setInterval(() => {
|
||||
// entity.tick();
|
||||
// }, 16.66);
|
||||
// await entity.die();
|
||||
// clearInterval(handle);
|
||||
// expect(didActions).to.be.true;
|
||||
// });
|
||||
// describe('Packets', () => {
|
||||
// let entity2;
|
||||
// beforeEach(async () => {
|
||||
// entity2 = await Entity.load({
|
||||
// traits: {
|
||||
// Alive: {},
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
// it('generates and accepts life packets', async () => {
|
||||
// entity.life = 80;
|
||||
// entity.maxLife = 90;
|
||||
// const packets = entity.trait('Alive').packetsFor();
|
||||
// expect(packets).to.have.lengthOf(1);
|
||||
// expect(packets[0][0]).to.equal('TraitUpdateAlive');
|
||||
// expect(packets[0][1]).to.deep.equal({life: 80, maxLife: 90});
|
||||
// entity2.trait('Alive').acceptPacket(normalize(flecks, packets[0]));
|
||||
// expect(entity2.life).to.equal(80);
|
||||
// expect(entity2.maxLife).to.equal(90);
|
||||
// });
|
||||
// if ('http' !== process.env.FLECKS_CORE_BUILD_TARGET) {
|
||||
// it('generates and accepts death packets', async () => {
|
||||
// entity.life = 0;
|
||||
// entity.tick();
|
||||
// const packets = entity.trait('Alive').packetsFor();
|
||||
// expect(packets).to.have.lengthOf(2);
|
||||
// expect(packets[0][0]).to.equal('Died');
|
||||
// expect(packets[1][0]).to.equal('TraitUpdateAlive');
|
||||
// expect(packets[1][1]).to.deep.equal({life: 0, maxLife: 100});
|
||||
// const promise = new Promise((resolve) => {
|
||||
// entity2.once('startedDying', resolve);
|
||||
// });
|
||||
// entity2.trait('Alive').acceptPacket(normalize(flecks, packets[0]));
|
||||
// entity2.trait('Alive').acceptPacket(normalize(flecks, packets[1]));
|
||||
// expect(entity2.life).to.equal(0);
|
||||
// return promise;
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
|
|
@ -1,58 +1,58 @@
|
|||
import {Latus} from '@latus/core';
|
||||
import {normalize} from '@latus/socket';
|
||||
import {expect} from 'chai';
|
||||
// import {Flecks} from '@flecks/core';
|
||||
// import {normalize} from '@flecks/socket';
|
||||
// import {expect} from 'chai';
|
||||
|
||||
let latus;
|
||||
let Entity;
|
||||
beforeEach(async () => {
|
||||
latus = Latus.mock({
|
||||
'@avocado/entity': require('../src'),
|
||||
'@avocado/resource': require('@avocado/resource'),
|
||||
'@avocado/traits': require('@avocado/traits'),
|
||||
'@latus/socket': require('@latus/socket'),
|
||||
});
|
||||
await Promise.all(latus.invokeFlat('@latus/core/starting'));
|
||||
({Entity} = latus.get('%resources'));
|
||||
});
|
||||
describe('Directional', () => {
|
||||
let entity;
|
||||
beforeEach(async () => {
|
||||
entity = await Entity.load({
|
||||
traits: {
|
||||
Directional: {
|
||||
params: {
|
||||
directionCount: 4,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
it('exists', async () => {
|
||||
expect(entity.is('Directional')).to.be.true;
|
||||
});
|
||||
it('tracks movement', async () => {
|
||||
entity.emit('movementRequest', [1, 0]);
|
||||
expect(entity.direction).to.equal(1);
|
||||
entity.emit('movementRequest', [0, 1]);
|
||||
expect(entity.direction).to.equal(2);
|
||||
entity.emit('movementRequest', [-1, 0]);
|
||||
expect(entity.direction).to.equal(3);
|
||||
entity.emit('movementRequest', [0, -1]);
|
||||
expect(entity.direction).to.equal(0);
|
||||
});
|
||||
it('generates and accepts direction packets', async () => {
|
||||
entity.direction = 2;
|
||||
const packets = entity.trait('Directional').packetsFor();
|
||||
expect(packets).to.have.lengthOf(1);
|
||||
expect(packets[0][0]).to.equal('TraitUpdateDirectionalDirection');
|
||||
expect(packets[0][1]).to.equal(2);
|
||||
const entity2 = await Entity.load({
|
||||
traits: {
|
||||
Directional: {},
|
||||
},
|
||||
});
|
||||
expect(entity2.direction).to.equal(0);
|
||||
entity2.trait('Directional').acceptPacket(normalize(latus, packets[0]));
|
||||
expect(entity2.direction).to.equal(2);
|
||||
});
|
||||
});
|
||||
// let flecks;
|
||||
// let Entity;
|
||||
// beforeEach(async () => {
|
||||
// flecks = Flecks.mock({
|
||||
// '@avocado/entity': require('../src'),
|
||||
// '@avocado/resource': require('@avocado/resource'),
|
||||
// '@avocado/traits': require('@avocado/traits'),
|
||||
// '@flecks/socket': require('@flecks/socket'),
|
||||
// });
|
||||
// await Promise.all(flecks.invokeFlat('@flecks/core/starting'));
|
||||
// ({Entity} = flecks.get('$avocado/resource.resources'));
|
||||
// });
|
||||
// describe('Directional', () => {
|
||||
// let entity;
|
||||
// beforeEach(async () => {
|
||||
// entity = await Entity.load({
|
||||
// traits: {
|
||||
// Directional: {
|
||||
// params: {
|
||||
// directionCount: 4,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
// it('exists', async () => {
|
||||
// expect(entity.is('Directional')).to.be.true;
|
||||
// });
|
||||
// it('tracks movement', async () => {
|
||||
// entity.emit('movementRequest', [1, 0]);
|
||||
// expect(entity.direction).to.equal(1);
|
||||
// entity.emit('movementRequest', [0, 1]);
|
||||
// expect(entity.direction).to.equal(2);
|
||||
// entity.emit('movementRequest', [-1, 0]);
|
||||
// expect(entity.direction).to.equal(3);
|
||||
// entity.emit('movementRequest', [0, -1]);
|
||||
// expect(entity.direction).to.equal(0);
|
||||
// });
|
||||
// it('generates and accepts direction packets', async () => {
|
||||
// entity.direction = 2;
|
||||
// const packets = entity.trait('Directional').packetsFor();
|
||||
// expect(packets).to.have.lengthOf(1);
|
||||
// expect(packets[0][0]).to.equal('TraitUpdateDirectionalDirection');
|
||||
// expect(packets[0][1]).to.equal(2);
|
||||
// const entity2 = await Entity.load({
|
||||
// traits: {
|
||||
// Directional: {},
|
||||
// },
|
||||
// });
|
||||
// expect(entity2.direction).to.equal(0);
|
||||
// entity2.trait('Directional').acceptPacket(normalize(flecks, packets[0]));
|
||||
// expect(entity2.direction).to.equal(2);
|
||||
// });
|
||||
// });
|
||||
|
|
|
@ -1,93 +1,93 @@
|
|||
import {Trait, traits} from '@avocado/traits';
|
||||
import {Latus} from '@latus/core';
|
||||
import {expect} from 'chai';
|
||||
// import {Trait, traits} from '@avocado/traits';
|
||||
// import {Flecks} from '@flecks/core';
|
||||
// import {expect} from 'chai';
|
||||
|
||||
let latus;
|
||||
let Entity;
|
||||
beforeEach(async () => {
|
||||
latus = Latus.mock({
|
||||
'@avocado/entity': require('../src'),
|
||||
'@avocado/resource': require('@avocado/resource'),
|
||||
'@avocado/traits': require('@avocado/traits'),
|
||||
});
|
||||
await Promise.all(latus.invokeFlat('@latus/core/starting'));
|
||||
({Entity} = latus.get('%resources'));
|
||||
});
|
||||
it('has sane defaults', () => {
|
||||
const entity = new Entity();
|
||||
expect(entity.traits).to.deep.equal({});
|
||||
expect(entity.traitTypes()).to.deep.equal([]);
|
||||
});
|
||||
it('can add and remove traits', async () => {
|
||||
const entity = new Entity();
|
||||
const TestTrait = class extends Trait {
|
||||
// let flecks;
|
||||
// let Entity;
|
||||
// beforeEach(async () => {
|
||||
// flecks = Flecks.mock({
|
||||
// '@avocado/entity': require('../src'),
|
||||
// '@avocado/resource': require('@avocado/resource'),
|
||||
// '@avocado/traits': require('@avocado/traits'),
|
||||
// });
|
||||
// await Promise.all(flecks.invokeFlat('@flecks/core/starting'));
|
||||
// ({Entity} = flecks.get('$avocado/resource.resources'));
|
||||
// });
|
||||
// it('has sane defaults', () => {
|
||||
// const entity = new Entity();
|
||||
// expect(entity.traits).to.deep.equal({});
|
||||
// expect(entity.traitTypes()).to.deep.equal([]);
|
||||
// });
|
||||
// it('can add and remove traits', async () => {
|
||||
// const entity = new Entity();
|
||||
// const TestTrait = class extends Trait {
|
||||
|
||||
static get type() {
|
||||
return 'TestTrait';
|
||||
}
|
||||
// static get type() {
|
||||
// return 'TestTrait';
|
||||
// }
|
||||
|
||||
};
|
||||
latus.set('%traits.TestTrait', TestTrait);
|
||||
await entity.addTrait('TestTrait');
|
||||
expect(entity.is('TestTrait')).to.be.true;
|
||||
entity.removeTrait('TestTrait');
|
||||
expect(entity.is('TestTrait')).to.be.false;
|
||||
});
|
||||
it('can add traits asynchronously', async () => {
|
||||
const DELAY = 30;
|
||||
class AsyncTrait extends Trait {
|
||||
// };
|
||||
// flecks.set('$avocado/traits.traits.TestTrait', TestTrait);
|
||||
// await entity.addTrait('TestTrait');
|
||||
// expect(entity.is('TestTrait')).to.be.true;
|
||||
// entity.removeTrait('TestTrait');
|
||||
// expect(entity.is('TestTrait')).to.be.false;
|
||||
// });
|
||||
// it('can add traits asynchronously', async () => {
|
||||
// const DELAY = 30;
|
||||
// class AsyncTrait extends Trait {
|
||||
|
||||
static async extendJson(json) {
|
||||
const extended = await super.extendJson(json);
|
||||
await new Promise((resolve) => setTimeout(resolve, DELAY));
|
||||
return extended;
|
||||
}
|
||||
// static async extendJson(json) {
|
||||
// const extended = await super.extendJson(json);
|
||||
// await new Promise((resolve) => setTimeout(resolve, DELAY));
|
||||
// return extended;
|
||||
// }
|
||||
|
||||
}
|
||||
latus.set('%traits.Async', AsyncTrait);
|
||||
let start = Date.now();
|
||||
const entity = await Entity.load({
|
||||
traits: {
|
||||
Async: {},
|
||||
},
|
||||
});
|
||||
expect(Date.now() - start).to.be.at.least(DELAY * 0.9);
|
||||
});
|
||||
it('can invoke hooks', async () => {
|
||||
class AnotherTrait extends Trait {
|
||||
// }
|
||||
// flecks.set('$avocado/traits.traits.Async', AsyncTrait);
|
||||
// let start = Date.now();
|
||||
// const entity = await Entity.load({
|
||||
// traits: {
|
||||
// Async: {},
|
||||
// },
|
||||
// });
|
||||
// expect(Date.now() - start).to.be.at.least(DELAY * 0.9);
|
||||
// });
|
||||
// it('can invoke hooks', async () => {
|
||||
// class AnotherTrait extends Trait {
|
||||
|
||||
hooks() {
|
||||
return {
|
||||
// hooks() {
|
||||
// return {
|
||||
|
||||
testHook: () => 69,
|
||||
// testHook: () => 69,
|
||||
|
||||
};
|
||||
}
|
||||
// };
|
||||
// }
|
||||
|
||||
static get type() {
|
||||
return 'AnotherTrait';
|
||||
}
|
||||
// static get type() {
|
||||
// return 'AnotherTrait';
|
||||
// }
|
||||
|
||||
}
|
||||
class YetAnotherTrait extends Trait {
|
||||
// }
|
||||
// class YetAnotherTrait extends Trait {
|
||||
|
||||
hooks() {
|
||||
return {
|
||||
// hooks() {
|
||||
// return {
|
||||
|
||||
testHook: () => 420,
|
||||
// testHook: () => 420,
|
||||
|
||||
};
|
||||
}
|
||||
// };
|
||||
// }
|
||||
|
||||
static get type() {
|
||||
return 'YetAnotherTrait';
|
||||
}
|
||||
// static get type() {
|
||||
// return 'YetAnotherTrait';
|
||||
// }
|
||||
|
||||
}
|
||||
latus.set('%traits.AnotherTrait', AnotherTrait);
|
||||
latus.set('%traits.YetAnotherTrait', YetAnotherTrait);
|
||||
const entity = new Entity();
|
||||
await entity.addTrait('AnotherTrait');
|
||||
await entity.addTrait('YetAnotherTrait');
|
||||
expect(entity.invokeHook('testHook')).to.deep.equal({AnotherTrait: 69, YetAnotherTrait: 420});
|
||||
});
|
||||
// }
|
||||
// flecks.set('$avocado/traits.traits.AnotherTrait', AnotherTrait);
|
||||
// flecks.set('$avocado/traits.traits.YetAnotherTrait', YetAnotherTrait);
|
||||
// const entity = new Entity();
|
||||
// await entity.addTrait('AnotherTrait');
|
||||
// await entity.addTrait('YetAnotherTrait');
|
||||
// expect(entity.invokeHook('testHook')).to.deep.equal({AnotherTrait: 69, YetAnotherTrait: 420});
|
||||
// });
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
import {expect} from 'chai';
|
||||
|
||||
it('exists', () => {
|
||||
expect(true).to.be.true;
|
||||
});
|
|
@ -1,59 +1,59 @@
|
|||
import {Latus} from '@latus/core';
|
||||
import {expect} from 'chai';
|
||||
// import {Flecks} from '@flecks/core';
|
||||
// import {expect} from 'chai';
|
||||
|
||||
let latus;
|
||||
let Entity;
|
||||
let EntityList;
|
||||
beforeEach(async () => {
|
||||
latus = Latus.mock({
|
||||
'@avocado/entity': require('../src'),
|
||||
'@avocado/resource': require('@avocado/resource'),
|
||||
'@avocado/traits': require('@avocado/traits'),
|
||||
});
|
||||
await Promise.all(latus.invokeFlat('@latus/core/starting'));
|
||||
({Entity, EntityList} = latus.get('%resources'));
|
||||
});
|
||||
describe('Mobile', () => {
|
||||
let entity;
|
||||
beforeEach(async () => {
|
||||
entity = await Entity.load({
|
||||
traits: {
|
||||
Mobile: {},
|
||||
Positioned: {},
|
||||
},
|
||||
});
|
||||
});
|
||||
it('exists', async () => {
|
||||
expect(entity.is('Mobile')).to.be.true;
|
||||
});
|
||||
it('can request movement', async () => {
|
||||
entity.speed = 100;
|
||||
entity.requestMovement([1, 0]);
|
||||
entity.tick(1);
|
||||
expect(entity.position).to.deep.equal([100, 0]);
|
||||
entity.tick(1);
|
||||
expect(entity.position).to.deep.equal([100, 0]);
|
||||
entity.isMobile = false;
|
||||
entity.requestMovement([1, 0]);
|
||||
entity.tick(1);
|
||||
expect(entity.position).to.deep.equal([100, 0]);
|
||||
});
|
||||
it('can force movement', async () => {
|
||||
expect(entity.speed).to.equal(0);
|
||||
entity.forceMovement([10, 0]);
|
||||
expect(entity.position).to.deep.equal([10, 0]);
|
||||
});
|
||||
it('can move for a time', async () => {
|
||||
entity.speed = 10;
|
||||
const tickingPromise = entity.moveFor([1, 0], 1);
|
||||
entity.addTickingPromise(tickingPromise);
|
||||
expect(entity.position).to.deep.equal([0, 0]);
|
||||
entity.tick(0.25);
|
||||
expect(entity.position).to.deep.equal([2.5, 0]);
|
||||
entity.tick(0.25);
|
||||
expect(entity.position).to.deep.equal([5, 0]);
|
||||
entity.tick(0.5);
|
||||
expect(entity.position).to.deep.equal([10, 0]);
|
||||
return tickingPromise;
|
||||
});
|
||||
});
|
||||
// let flecks;
|
||||
// let Entity;
|
||||
// let EntityList;
|
||||
// beforeEach(async () => {
|
||||
// flecks = Flecks.mock({
|
||||
// '@avocado/entity': require('../src'),
|
||||
// '@avocado/resource': require('@avocado/resource'),
|
||||
// '@avocado/traits': require('@avocado/traits'),
|
||||
// });
|
||||
// await Promise.all(flecks.invokeFlat('@flecks/core/starting'));
|
||||
// ({Entity, EntityList} = flecks.get('$avocado/resource.resources'));
|
||||
// });
|
||||
// describe('Mobile', () => {
|
||||
// let entity;
|
||||
// beforeEach(async () => {
|
||||
// entity = await Entity.load({
|
||||
// traits: {
|
||||
// Mobile: {},
|
||||
// Positioned: {},
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
// it('exists', async () => {
|
||||
// expect(entity.is('Mobile')).to.be.true;
|
||||
// });
|
||||
// it('can request movement', async () => {
|
||||
// entity.speed = 100;
|
||||
// entity.requestMovement([1, 0]);
|
||||
// entity.tick(1);
|
||||
// expect(entity.position).to.deep.equal([100, 0]);
|
||||
// entity.tick(1);
|
||||
// expect(entity.position).to.deep.equal([100, 0]);
|
||||
// entity.isMobile = false;
|
||||
// entity.requestMovement([1, 0]);
|
||||
// entity.tick(1);
|
||||
// expect(entity.position).to.deep.equal([100, 0]);
|
||||
// });
|
||||
// it('can force movement', async () => {
|
||||
// expect(entity.speed).to.equal(0);
|
||||
// entity.forceMovement([10, 0]);
|
||||
// expect(entity.position).to.deep.equal([10, 0]);
|
||||
// });
|
||||
// it('can move for a time', async () => {
|
||||
// entity.speed = 10;
|
||||
// const tickingPromise = entity.moveFor([1, 0], 1);
|
||||
// entity.addTickingPromise(tickingPromise);
|
||||
// expect(entity.position).to.deep.equal([0, 0]);
|
||||
// entity.tick(0.25);
|
||||
// expect(entity.position).to.deep.equal([2.5, 0]);
|
||||
// entity.tick(0.25);
|
||||
// expect(entity.position).to.deep.equal([5, 0]);
|
||||
// entity.tick(0.5);
|
||||
// expect(entity.position).to.deep.equal([10, 0]);
|
||||
// return tickingPromise;
|
||||
// });
|
||||
// });
|
||||
|
|
|
@ -1,44 +1,44 @@
|
|||
import {Latus} from '@latus/core';
|
||||
import {expect} from 'chai';
|
||||
// import {Flecks} from '@flecks/core';
|
||||
// import {expect} from 'chai';
|
||||
|
||||
let latus;
|
||||
let Entity;
|
||||
let EntityList;
|
||||
beforeEach(async () => {
|
||||
latus = Latus.mock({
|
||||
'@avocado/entity': require('../src'),
|
||||
'@avocado/resource': require('@avocado/resource'),
|
||||
'@avocado/traits': require('@avocado/traits'),
|
||||
});
|
||||
await Promise.all(latus.invokeFlat('@latus/core/starting'));
|
||||
({Entity, EntityList} = latus.get('%resources'));
|
||||
});
|
||||
describe('Perishable', () => {
|
||||
let entity;
|
||||
beforeEach(async () => {
|
||||
entity = await Entity.load({
|
||||
traits: {
|
||||
Perishable: {
|
||||
params: {
|
||||
ttl: 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
it('exists', async () => {
|
||||
expect(entity.is('Perishable')).to.be.true;
|
||||
});
|
||||
it('expires', async () => {
|
||||
const promise = Promise.all([
|
||||
new Promise((resolve) => {
|
||||
entity.on('destroying', resolve);
|
||||
}),
|
||||
new Promise((resolve) => {
|
||||
entity.on('destroyed', resolve);
|
||||
}),
|
||||
]);
|
||||
entity.tick(10);
|
||||
return promise;
|
||||
});
|
||||
});
|
||||
// let flecks;
|
||||
// let Entity;
|
||||
// let EntityList;
|
||||
// beforeEach(async () => {
|
||||
// flecks = Flecks.mock({
|
||||
// '@avocado/entity': require('../src'),
|
||||
// '@avocado/resource': require('@avocado/resource'),
|
||||
// '@avocado/traits': require('@avocado/traits'),
|
||||
// });
|
||||
// await Promise.all(flecks.invokeFlat('@flecks/core/starting'));
|
||||
// ({Entity, EntityList} = flecks.get('$avocado/resource.resources'));
|
||||
// });
|
||||
// describe('Perishable', () => {
|
||||
// let entity;
|
||||
// beforeEach(async () => {
|
||||
// entity = await Entity.load({
|
||||
// traits: {
|
||||
// Perishable: {
|
||||
// params: {
|
||||
// ttl: 10,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
// it('exists', async () => {
|
||||
// expect(entity.is('Perishable')).to.be.true;
|
||||
// });
|
||||
// it('expires', async () => {
|
||||
// const promise = Promise.all([
|
||||
// new Promise((resolve) => {
|
||||
// entity.on('destroying', resolve);
|
||||
// }),
|
||||
// new Promise((resolve) => {
|
||||
// entity.on('destroyed', resolve);
|
||||
// }),
|
||||
// ]);
|
||||
// entity.tick(10);
|
||||
// return promise;
|
||||
// });
|
||||
// });
|
||||
|
|
|
@ -1,48 +1,48 @@
|
|||
import {Latus} from '@latus/core';
|
||||
import {normalize} from '@latus/socket';
|
||||
import {expect} from 'chai';
|
||||
// import {Flecks} from '@flecks/core';
|
||||
// import {normalize} from '@flecks/socket';
|
||||
// import {expect} from 'chai';
|
||||
|
||||
let latus;
|
||||
let Entity;
|
||||
let EntityList;
|
||||
beforeEach(async () => {
|
||||
latus = Latus.mock({
|
||||
'@avocado/entity': require('../src'),
|
||||
'@avocado/resource': require('@avocado/resource'),
|
||||
'@avocado/traits': require('@avocado/traits'),
|
||||
'@latus/socket': require('@latus/socket'),
|
||||
});
|
||||
await Promise.all(latus.invokeFlat('@latus/core/starting'));
|
||||
({Entity, EntityList} = latus.get('%resources'));
|
||||
});
|
||||
describe('Positioned', () => {
|
||||
let entity;
|
||||
beforeEach(async () => {
|
||||
entity = await Entity.load({
|
||||
traits: {
|
||||
Positioned: {},
|
||||
},
|
||||
});
|
||||
});
|
||||
it('exists', async () => {
|
||||
expect(entity.is('Positioned')).to.be.true;
|
||||
});
|
||||
if ('client' !== process.env.SIDE) {
|
||||
it('generates and accepts movement packets', async () => {
|
||||
entity.setPosition([1, 1]);
|
||||
const packets = entity.trait('Positioned').packetsFor();
|
||||
expect(packets).to.have.lengthOf(1);
|
||||
expect(packets[0][0]).to.equal('TraitUpdatePositionedPosition');
|
||||
expect(packets[0][1]).to.deep.equal([1, 1]);
|
||||
const entity2 = await Entity.load({
|
||||
traits: {
|
||||
Positioned: {},
|
||||
},
|
||||
});
|
||||
expect(entity2.position).to.deep.equal([0, 0]);
|
||||
const trait = entity2.trait('Positioned');
|
||||
trait.acceptPacket(normalize(latus, packets[0]));
|
||||
expect(trait.serverPosition).to.deep.equal([1, 1]);
|
||||
});
|
||||
}
|
||||
});
|
||||
// let flecks;
|
||||
// let Entity;
|
||||
// let EntityList;
|
||||
// beforeEach(async () => {
|
||||
// flecks = Flecks.mock({
|
||||
// '@avocado/entity': require('../src'),
|
||||
// '@avocado/resource': require('@avocado/resource'),
|
||||
// '@avocado/traits': require('@avocado/traits'),
|
||||
// '@flecks/socket': require('@flecks/socket'),
|
||||
// });
|
||||
// await Promise.all(flecks.invokeFlat('@flecks/core/starting'));
|
||||
// ({Entity, EntityList} = flecks.get('$avocado/resource.resources'));
|
||||
// });
|
||||
// describe('Positioned', () => {
|
||||
// let entity;
|
||||
// beforeEach(async () => {
|
||||
// entity = await Entity.load({
|
||||
// traits: {
|
||||
// Positioned: {},
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
// it('exists', async () => {
|
||||
// expect(entity.is('Positioned')).to.be.true;
|
||||
// });
|
||||
// if ('http' !== process.env.FLECKS_CORE_BUILD_TARGET) {
|
||||
// it('generates and accepts movement packets', async () => {
|
||||
// entity.setPosition([1, 1]);
|
||||
// const packets = entity.trait('Positioned').packetsFor();
|
||||
// expect(packets).to.have.lengthOf(1);
|
||||
// expect(packets[0][0]).to.equal('TraitUpdatePositionedPosition');
|
||||
// expect(packets[0][1]).to.deep.equal([1, 1]);
|
||||
// const entity2 = await Entity.load({
|
||||
// traits: {
|
||||
// Positioned: {},
|
||||
// },
|
||||
// });
|
||||
// expect(entity2.position).to.deep.equal([0, 0]);
|
||||
// const trait = entity2.trait('Positioned');
|
||||
// trait.acceptPacket(normalize(flecks, packets[0]));
|
||||
// expect(trait.serverPosition).to.deep.equal([1, 1]);
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
|
|
|
@ -1,89 +1,89 @@
|
|||
import {Latus} from '@latus/core';
|
||||
import {expect} from 'chai';
|
||||
// import {Flecks} from '@flecks/core';
|
||||
// import {expect} from 'chai';
|
||||
|
||||
let latus;
|
||||
let Entity;
|
||||
let EntityList;
|
||||
beforeEach(async () => {
|
||||
latus = Latus.mock({
|
||||
'@avocado/behavior': require('@avocado/behavior'),
|
||||
'@avocado/entity': require('../src'),
|
||||
'@avocado/resource': require('@avocado/resource'),
|
||||
'@avocado/traits': require('@avocado/traits'),
|
||||
});
|
||||
await Promise.all(latus.invokeFlat('@latus/core/starting'));
|
||||
({Entity, EntityList} = latus.get('%resources'));
|
||||
});
|
||||
describe('Spawner', () => {
|
||||
let entity;
|
||||
let list;
|
||||
beforeEach(async () => {
|
||||
entity = await Entity.load({
|
||||
traits: {
|
||||
Spawner: {
|
||||
params: {
|
||||
spawns: {
|
||||
testy: {
|
||||
traits: {
|
||||
Alive: {},
|
||||
Positioned: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
list = new EntityList();
|
||||
list.addEntity(entity);
|
||||
});
|
||||
it('exists', async () => {
|
||||
expect(entity.is('Spawner')).to.be.true;
|
||||
});
|
||||
it('can spawn from key', async () => {
|
||||
const spawned = await entity.spawn('testy');
|
||||
expect(spawned.is('Alive')).to.be.true;
|
||||
const spawned2 = await entity.spawn('testy', {
|
||||
traits: {
|
||||
Alive: {
|
||||
state: {
|
||||
life: 50,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(spawned2.life).to.equal(50);
|
||||
const spawned3 = await entity.spawnAt('testy', [69, 420]);
|
||||
expect(spawned3.position).to.deep.equal([69, 420]);
|
||||
});
|
||||
it('can spawn from arbitrary JSON', async () => {
|
||||
const spawned = await entity.spawnRaw({
|
||||
traits: {
|
||||
Mobile: {},
|
||||
},
|
||||
});
|
||||
expect(spawned.is('Mobile')).to.be.true;
|
||||
const spawned2 = await entity.spawnRawAt(
|
||||
{
|
||||
traits: {
|
||||
Mobile: {},
|
||||
},
|
||||
},
|
||||
[311, 200],
|
||||
);
|
||||
expect(spawned2.position).to.deep.equal([311, 200]);
|
||||
});
|
||||
it('can kill all children', async () => {
|
||||
const COUNT = 15;
|
||||
for (let i = 0; i < COUNT; ++i) {
|
||||
await entity.spawnRaw({
|
||||
traits: {
|
||||
Mobile: {},
|
||||
},
|
||||
});
|
||||
}
|
||||
expect(Object.keys(list.entities)).to.have.lengthOf(COUNT + 1);
|
||||
await entity.killAllChildren();
|
||||
expect(Object.keys(list.entities)).to.have.lengthOf(1);
|
||||
});
|
||||
});
|
||||
// let flecks;
|
||||
// let Entity;
|
||||
// let EntityList;
|
||||
// beforeEach(async () => {
|
||||
// flecks = Flecks.mock({
|
||||
// '@avocado/behavior': require('@avocado/behavior'),
|
||||
// '@avocado/entity': require('../src'),
|
||||
// '@avocado/resource': require('@avocado/resource'),
|
||||
// '@avocado/traits': require('@avocado/traits'),
|
||||
// });
|
||||
// await Promise.all(flecks.invokeFlat('@flecks/core/starting'));
|
||||
// ({Entity, EntityList} = flecks.get('$avocado/resource.resources'));
|
||||
// });
|
||||
// describe('Spawner', () => {
|
||||
// let entity;
|
||||
// let list;
|
||||
// beforeEach(async () => {
|
||||
// entity = await Entity.load({
|
||||
// traits: {
|
||||
// Spawner: {
|
||||
// params: {
|
||||
// spawns: {
|
||||
// testy: {
|
||||
// traits: {
|
||||
// Alive: {},
|
||||
// Positioned: {},
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// list = new EntityList();
|
||||
// list.addEntity(entity);
|
||||
// });
|
||||
// it('exists', async () => {
|
||||
// expect(entity.is('Spawner')).to.be.true;
|
||||
// });
|
||||
// it('can spawn from key', async () => {
|
||||
// const spawned = await entity.spawn('testy');
|
||||
// expect(spawned.is('Alive')).to.be.true;
|
||||
// const spawned2 = await entity.spawn('testy', {
|
||||
// traits: {
|
||||
// Alive: {
|
||||
// state: {
|
||||
// life: 50,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// expect(spawned2.life).to.equal(50);
|
||||
// const spawned3 = await entity.spawnAt('testy', [69, 420]);
|
||||
// expect(spawned3.position).to.deep.equal([69, 420]);
|
||||
// });
|
||||
// it('can spawn from arbitrary JSON', async () => {
|
||||
// const spawned = await entity.spawnRaw({
|
||||
// traits: {
|
||||
// Mobile: {},
|
||||
// },
|
||||
// });
|
||||
// expect(spawned.is('Mobile')).to.be.true;
|
||||
// const spawned2 = await entity.spawnRawAt(
|
||||
// {
|
||||
// traits: {
|
||||
// Mobile: {},
|
||||
// },
|
||||
// },
|
||||
// [311, 200],
|
||||
// );
|
||||
// expect(spawned2.position).to.deep.equal([311, 200]);
|
||||
// });
|
||||
// it('can kill all children', async () => {
|
||||
// const COUNT = 15;
|
||||
// for (let i = 0; i < COUNT; ++i) {
|
||||
// await entity.spawnRaw({
|
||||
// traits: {
|
||||
// Mobile: {},
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// expect(Object.keys(list.entities)).to.have.lengthOf(COUNT + 1);
|
||||
// await entity.killAllChildren();
|
||||
// expect(Object.keys(list.entities)).to.have.lengthOf(1);
|
||||
// });
|
||||
// });
|
||||
|
|
File diff suppressed because it is too large
Load Diff
124
packages/graphics-persea/.gitignore
vendored
124
packages/graphics-persea/.gitignore
vendored
|
@ -1,8 +1,116 @@
|
|||
**/*.js
|
||||
**/*.map
|
||||
/assets
|
||||
!/.*
|
||||
!/postcss.config.js
|
||||
!/webpack.config.js
|
||||
!src/**/*.js
|
||||
!/test/**/*.js
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
|
6
packages/graphics-persea/build/flecks.yml
Normal file
6
packages/graphics-persea/build/flecks.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
'@flecks/core': {}
|
||||
'@flecks/fleck': {}
|
||||
'@flecks/http': {}
|
||||
'@flecks/http/server':
|
||||
build: false
|
||||
'@flecks/react': {}
|
|
@ -1,25 +1,35 @@
|
|||
{
|
||||
"version": "1.0.0",
|
||||
"name": "@avocado/graphics-persea",
|
||||
"version": "3.0.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.hq.cha0s.io/cha0s/avocado.git",
|
||||
"directory": "packages/graphics-persea"
|
||||
},
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "latus-build",
|
||||
"clean": "latus-build clean",
|
||||
"fp": "latus-build forcepublish",
|
||||
"lint": "latus-build lint",
|
||||
"test": "latus-build test"
|
||||
"build": "flecks build",
|
||||
"clean": "flecks clean",
|
||||
"lint": "flecks lint",
|
||||
"postversion": "cp package.json dist",
|
||||
"test": "flecks test"
|
||||
},
|
||||
"files": [
|
||||
"build",
|
||||
"index.js",
|
||||
"index.js.map",
|
||||
"src",
|
||||
"test",
|
||||
"test.js",
|
||||
"test.js.map"
|
||||
],
|
||||
"dependencies": {
|
||||
"@avocado/resource-persea": "^1.0.0",
|
||||
"@latus/react": "^2.0.0"
|
||||
"@avocado/resource-persea": "^3.0.0",
|
||||
"@flecks/core": "^1.3.0",
|
||||
"@flecks/react": "^1.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@latus/build": "1.x"
|
||||
},
|
||||
"name": "@avocado/graphics-persea"
|
||||
"@flecks/fleck": "^1.3.0",
|
||||
"@flecks/http": "^1.3.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import './component.scss';
|
|||
import {
|
||||
PropTypes,
|
||||
React,
|
||||
} from '@latus/react';
|
||||
} from '@flecks/react';
|
||||
|
||||
const ImageComponent = ({resource}) => {
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import {Hooks} from '@flecks/core';
|
||||
|
||||
import ImageController from './controllers/image';
|
||||
|
||||
export {
|
||||
|
@ -5,8 +7,8 @@ export {
|
|||
};
|
||||
|
||||
export default {
|
||||
hooks: {
|
||||
'@avocado/resource-persea/controllers': () => [
|
||||
[Hooks]: {
|
||||
'@avocado/resource-persea.controllers': () => [
|
||||
ImageController,
|
||||
],
|
||||
},
|
||||
|
|
File diff suppressed because it is too large
Load Diff
122
packages/graphics/.gitignore
vendored
122
packages/graphics/.gitignore
vendored
|
@ -1,6 +1,116 @@
|
|||
**/*.js
|
||||
**/*.map
|
||||
/assets
|
||||
!/.*
|
||||
!src/**/*.js
|
||||
!/test/**/*.js
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = () => ({
|
||||
dependencies: {
|
||||
dom: [
|
||||
module.exports = {
|
||||
stubs: {
|
||||
server: [
|
||||
'@pixi/constants',
|
||||
'@pixi/core',
|
||||
'@pixi/display',
|
||||
|
@ -16,4 +16,4 @@ module.exports = () => ({
|
|||
'@pixi/text',
|
||||
],
|
||||
},
|
||||
});
|
||||
};
|
6
packages/graphics/build/flecks.yml
Normal file
6
packages/graphics/build/flecks.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
'@flecks/core': {}
|
||||
'@flecks/fleck': {}
|
||||
'@flecks/http': {}
|
||||
'@flecks/http/server':
|
||||
build: false
|
||||
'@flecks/react': {}
|
|
@ -1,32 +1,38 @@
|
|||
{
|
||||
"name": "@avocado/graphics",
|
||||
"version": "2.0.0",
|
||||
"version": "3.0.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.hq.cha0s.io/cha0s/avocado.git",
|
||||
"directory": "packages/graphics"
|
||||
},
|
||||
"main": "index.js",
|
||||
"author": "cha0s",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "latus-build",
|
||||
"clean": "latus-build clean",
|
||||
"fp": "latus-build forcepublish",
|
||||
"lint": "latus-build lint",
|
||||
"test": "latus-build test"
|
||||
"build": "flecks build",
|
||||
"clean": "flecks clean",
|
||||
"lint": "flecks lint",
|
||||
"postversion": "cp package.json dist",
|
||||
"test": "flecks test"
|
||||
},
|
||||
"files": [
|
||||
".flecksrc.js",
|
||||
"build",
|
||||
"index.js",
|
||||
"index.js.map",
|
||||
".latusrc.js",
|
||||
"test/fixtures",
|
||||
"src",
|
||||
"test",
|
||||
"test.js",
|
||||
"test.js.map"
|
||||
"test.js.map",
|
||||
"test/fixtures"
|
||||
],
|
||||
"dependencies": {
|
||||
"@avocado/core": "2.0.0",
|
||||
"@avocado/math": "2.0.0",
|
||||
"@avocado/resource": "2.0.0",
|
||||
"@avocado/traits": "^2.0.0",
|
||||
"@latus/core": "^2.0.0",
|
||||
"@latus/react": "^2.0.0",
|
||||
"@latus/socket": "2.0.0",
|
||||
"@avocado/core": "^3.0.0",
|
||||
"@avocado/math": "^3.0.0",
|
||||
"@avocado/resource": "^3.0.0",
|
||||
"@flecks/core": "^1.3.0",
|
||||
"@flecks/react": "^1.3.0",
|
||||
"@pixi/constants": "^5.3.9",
|
||||
"@pixi/core": "^5.3.9",
|
||||
"@pixi/display": "^5.3.9",
|
||||
|
@ -44,6 +50,7 @@
|
|||
"rc-slider": "^9.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@latus/build": "1.x"
|
||||
"@flecks/fleck": "^1.3.0",
|
||||
"@flecks/http": "^1.3.0"
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user