Skip to content

Instantly share code, notes, and snippets.

@tobiu
tobiu / Base.mjs
Created January 24, 2023 22:00
Neo.core.Base
/**
* The base class for (almost) all classes inside the Neo namespace
* Exceptions are e.g. core.IdGenerator, vdom.VNode
* @class Neo.core.Base
*/
class Base {
/**
* Set this one to false in case you don't want to stick
* to the "anti-pattern" to apply classes to the global Neo or App namespace
* @member {Boolean} registerToGlobalNs=true
@tobiu
tobiu / Base.mjs
Created January 24, 2023 21:58
Neo.core.Base
/**
* The base class for (almost) all classes inside the Neo namespace
* Exceptions are e.g. core.IdGenerator, vdom.VNode
* @class Neo.core.Base
*/
class Base {
/**
* The return value will get applied to the class constructor
* @returns {Object} staticConfig
* @static
@tobiu
tobiu / Canvas.mjs
Created September 6, 2022 21:22
Neo.component.Canvas
import Component from './Base.mjs';
/**
* @class Neo.component.Canvas
* @extends Neo.component.Base
*/
class Canvas extends Component {
static getConfig() {return {
/**
* @member {String} className='Neo.component.Canvas'
@tobiu
tobiu / MainContainerController.mjs
Last active September 6, 2022 21:07
MainApp.view.MainContainerController
import Component from '../../../node_modules/neo.mjs/src/controller/Component.mjs';
import NeoArray from '../../../node_modules/neo.mjs/src/util/Array.mjs';
/**
* @class MainApp.view.MainContainerController
* @extends Neo.controller.Component
*/
class MainContainerController extends Component {
/**
* @member {String[]} connectedApps=[]
@tobiu
tobiu / MainContainer.mjs
Created September 6, 2022 21:00
shared-offscreen/blob/main/apps/childapp/view/MainContainer.mjs
import Viewport from '../../../node_modules/neo.mjs/src/container/Viewport.mjs';
/**
* @class ChildApp.view.MainContainer
* @extends Neo.container.Viewport
*/
class MainContainer extends Viewport {
static getConfig() {return {
/*
* @member {String} className='ChildApp.view.MainContainer'
@tobiu
tobiu / neo-config.json
Created September 6, 2022 20:55
neo-config.json
{
"appPath": "../../apps/mainapp/app.mjs",
"basePath": "../../",
"environment": "development",
"mainPath": "../node_modules/neo.mjs/src/Main.mjs",
"useCanvasWorker": true,
"useSharedWorkers": true,
"workerBasePath": "../../node_modules/neo.mjs/src/worker/"
}
@tobiu
tobiu / ServiceWorker.mjs
Created March 28, 2022 08:13
Neo.main.addon.ServiceWorker
import Base from '../../core/Base.mjs';
import WorkerManager from '../../worker/Manager.mjs';
/**
* Creates a ServiceWorker instance, in case Neo.config.useServiceWorker is set to true
* @class Neo.main.addon.ServiceWorker
* @extends Neo.core.Base
* @singleton
*/
class ServiceWorker extends Base {
@tobiu
tobiu / ServiceBase.mjs
Created March 28, 2022 08:05
Neo.worker.ServiceBase
class ServiceBase extends Base {
// ...
cachePaths = [
'raw.githubusercontent.com/',
'/dist/production/',
'/fontawesome',
'/resources/'
]
}
@tobiu
tobiu / ServiceWorker.mjs
Created March 28, 2022 07:48
Neo.ServiceWorker
import Neo from '../src/Neo.mjs';
import * as core from '../src/core/_export.mjs';
import ServiceBase from '../src/worker/ServiceBase.mjs';
/**
* @class Neo.ServiceWorker
* @extends Neo.worker.ServiceBase
* @singleton
*/
class ServiceWorker extends ServiceBase {
@tobiu
tobiu / ServiceBase.mjs
Created March 28, 2022 07:25
Neo.worker.ServiceBase
class ServiceBase extends Base {
// ..
/**
* @param {Client} client
*/
createMessageChannel(client) {
let me = this,
channel = new MessageChannel(),
port = channel.port2;