npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

yueji

v0.11.4

Published

没有虚拟机,不要jit,直接把js编译成机器码,而不是附加一个解释器。

Downloads

6

Readme

月季

没有虚拟机,不要jit,直接把js编译成机器码。当前版本仅支持windows系统x86核心,少量的js语法及简单的dll调用,暂无内置的js对象。

用法

  • 全局安装后使用。全局安装的命令为 npm install -g yueji
  • 暂不支持没有nodejs的用户使用。
  • 由于本编译器生成的机器码与其他中老年语言的机器码的结构都不一样,可能会被Windows Defender误诊为病毒。如果被误诊,将其设置为允许运行即可。

编译代码

yueji 文件名.js

运行生成的文件

文件名.exe

指定生成的文件的版本及版权信息

目前支持修改的字段有 OriginalFilename ProductName LegalCopyright InternalName FileDescription CompanyName ProductVersion

yueji 文件名.js?ProductName=...,CompanyName=...,LegalCopyright=...

嵌入式数据

数据预处理器使用模板串的方法将文本数据转换成对应的二进制数据并嵌入到可执行文件。

  • HEXH,16进制文本转成二进制数据,中间可以有空格 如:
H`af ca dd aa`
  • GUIDG,GUID格式的字符串转GUID二进制 如:
Guid`23170f69-40c1-278a-1000-000110070000`
  • BYTEB, 0到255之间的整数数组,用逗号或空格分开。
  • WORDW, 0到65535之间的整数数组,用逗号或空格分开。
  • DWORDUINTINTN, 四字节整数数组,用逗号或空格分开。
  • UTF16LU,使用utf16-le编码的字符串。
  • Brizer,将贝塞尔曲线的控制点坐标转换为曲线点坐标数组,单精度。
  • realdecimalm,10进制单精度坐标数组 其中brizerdecimal前级可传入变换参数(缩放, x位移, y位移)(缩放, x位移, y位移, z位移)。 如:
M(1,0,0)`2,3,4,235,4,2`;
  • DATAD,从文件读入数据。 如:
D`./index.html`

特殊语法,区别于js的部分

可用标签指定变量的结构体类型

typescript不同的是,标签不放到参数中,而是放在函数体中。 同一个变量可以在不同的地方拥有不同的类型。 指定一个临时的类型,主要是为了方便访问结构体的属性。

    // 类似汇编语句 assume b:EFRONT_BUTTON,c:EFRONT_BUTTON,d:EFRONt_BUTTON
    // EFRONT_BUTTON是已在.inc或.h文件中定义的结构体
    EFRONT_BUTTON: b,c,d;
    EFRONT_BUTTON: var b,c,d; // 这种写法会被vscode警告

可以用defer标签延迟执行语句

defer标签类似go语言中的defer指令

    defer: CloseHandle(h1),CloseHandle(h2);// 语句延迟
    defer: { /* 语句块延迟*/ }
    defer: if(/*延时条件*/){} else;
    if(/*即时条件*/) defer:{
    }
    // ...

示例代码

下文中提到的二进制的dll和头文件,现已在开源仓库提供

  • github地址 https://github.com/yunxu1019/yueji-samples

  • gitee地址 https://gitee.com/jams/yueji-samples (国内访问较快)

Hello World

import { MessageBoxW } from "user32.dll"
// MessageBoxW的用法参考微软文档
// https://learn.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-messageboxw
MessageBoxW(null, "你好月季", "中文原创", 0);

Hello World 2 - 手搓 print

import { GetStdHandle, WriteConsoleW, AttachConsole, AllocConsole, FreeConsole, ExitProcess } from "kernel32.dll";
import "include/windows.inc";
if (!AttachConsole(-1/*parent*/)) AllocConsole();
// 如果前边不想导入耗时的头文件,这里可用-11代替STD_OUTPUT_HANDLE
var output = GetStdHandle(STD_OUTPUT_HANDLE/*-11*/);
function print(a) {
    WriteConsoleW(output, a, a.length, 0, 0);
}

print("你好月季,中文原创!")

在windows上实现pwd

import { GetModuleFileNameW, WriteConsoleW, GetStdHandle } from "kernel32.dll";
import { buffer, Utf16, dirname } from "yueji";
import "include/windows.inc";
// 目前支持使用.h和.inc文件中定义的常量和结构体,但有些头文件中的宏可能处理的不到位,会加载失败
var output = GetStdHandle(STD_OUTPUT_HANDLE);
var moduleFileName = buffer(8192);
GetModuleFileNameW(null, moduleFileName, 8192);
moduleFileName = Utf16(moduleFileName);
var folderName = dirname(moduleFileName);
WriteConsoleW(output, folderName, folderName.length, 0, 0);

其他示例

用sdl2演示排序算法

源码链接 https://github.com/yunxu1019/yueji-samples/blob/main/sdl-demo.js

用miniblink加载web应用

源码链接(普通用户) https://github.com/yunxu1019/yueji-samples/blob/main/blink.js 源码链接(vip适用) https://github.com/yunxu1019/yueji-samples/blob/main/blink-vip.js

用windows api创建原生窗口

源码链接 https://github.com/yunxu1019/yueji-samples/blob/main/winup.js

赞助

如果您希望项目快速迭代,请为此项目的开发者注资。

混入我们

QQ群: 710029752