Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

demoon

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

demoon - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

4

package.json
{
"name": "demoon",
"version": "0.0.8",
"version": "0.0.9",
"description": "Lua + Node",

@@ -16,4 +16,4 @@ "main": "src/index.js",

"dependencies": {
"wasmoon": "1.12.1"
"wasmoon": "1.15.0"
}
}

@@ -5,2 +5,4 @@ # demoon

> Don't use this in production!
## Usage

@@ -7,0 +9,0 @@

@@ -1,2 +0,2 @@

const { LuaFactory, LuaMultiReturn } = require('wasmoon')
const { LuaFactory, LuaEngine } = require('wasmoon')
const path = require('path')

@@ -6,44 +6,76 @@ const FunctionClassTypeExtension = require('./legacyclasses')

const start = async (entryFile, arg) => {
const factory = new LuaFactory(undefined, process.env)
module.exports = class {
/** @returns {Promise<LuaEngine>} */
async getLuaEngine() {
await this.#setupIfNeeded()
return this.#engine
}
const fullEntryFile = path.resolve(process.cwd(), entryFile)
const fullStdFile = path.resolve(__dirname, "std.lua")
/**
* @param {string} file
* @returns {Promise<void>}
*/
async runFile(file) {
await this.#setupIfNeeded()
await factory.mountFile(fullEntryFile, await fs.readFile(fullEntryFile))
await factory.mountFile(fullStdFile, await fs.readFile(fullStdFile))
this.#factory.mountFileSync(await this.#factory.getLuaModule(), file, await fs.readFile(file))
const engine = await factory.createEngine({ injectObjects: true })
try {
const thread = this.#engine.global.newThread()
thread.loadFile(file)
engine.global.registerTypeExtension(10, new FunctionClassTypeExtension)
engine.global.set('arg', arg)
engine.global.set('typeof', value => typeof value)
engine.global.set('instanceof', (value, type) => value instanceof type)
engine.global.set('new', (constructor, ...args) => new constructor(...args))
engine.global.set('global', global)
engine.global.set('mountFile', factory.mountFileSync.bind(factory))
engine.global.set('jsRequire', (modulename, metaDirectory) => {
if (metaDirectory) {
if (modulename.startsWith('.')) {
modulename = path.resolve(metaDirectory, '..', modulename)
}
this.#engine.global.set('jsRequire', (modulename, metaDirectory) => {
if (metaDirectory) {
if (modulename.startsWith('.')) {
modulename = path.resolve(metaDirectory, '..', modulename)
}
modulename = require.resolve(modulename, { paths: [fullEntryFile] })
modulename = require.resolve(modulename, { paths: [file] })
}
return module.require(modulename)
})
await thread.run(0)
} catch (e) {
console.error(e)
}
}
return module.require(modulename)
})
/** @type {LuaEngine | undefined} */
#engine
try {
engine.doFileSync(fullStdFile)
const thread = engine.global.newThread()
thread.loadFile(fullEntryFile)
await thread.run(0)
} catch (e) {
console.error(e)
/** @type {LuaFactory | undefined} */
#factory
async #setupIfNeeded() {
if (this.#factory) return
this.#factory = new LuaFactory(undefined, process.env)
const luamodule = await this.#factory.getLuaModule()
const fullStdFile = path.resolve(__dirname, "std.lua")
this.#factory.mountFileSync(luamodule, fullStdFile, await fs.readFile(fullStdFile))
this.#engine = await this.#factory.createEngine({ injectObjects: true })
this.#engine.global.registerTypeExtension(10, new FunctionClassTypeExtension)
this.#engine.global.set('typeof', value => typeof value)
this.#engine.global.set('instanceof', (value, type) => value instanceof type)
this.#engine.global.set('new', (constructor, ...args) => new constructor(...args))
this.#engine.global.set('global', global)
this.#engine.global.set('mountFile', (path, content) => this.#factory.mountFileSync(luamodule, path, content))
this.#engine.global.set('jsRequire', (modulename, metaDirectory) => {
if (metaDirectory) {
if (modulename.startsWith('.')) {
modulename = path.resolve(metaDirectory, '..', modulename)
}
modulename = require.resolve(modulename)
}
return module.require(modulename)
})
this.#engine.doFileSync(fullStdFile)
}
}
module.exports = { start }
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc