hsml 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Christopher Quadflieg
3
+ Copyright (c) 2023-2026 Christopher Quadflieg
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,35 +1,258 @@
1
- <p>
2
- <a href="https://github.com/Shinigami92/hsml/actions/workflows/ci.yml">
3
- <img alt="Build Status" src="https://github.com/Shinigami92/hsml/actions/workflows/ci.yml/badge.svg?branch=main">
4
- </a>
5
- <a href="https://github.com/Shinigami92/hsml/blob/main/LICENSE">
6
- <img alt="License: MIT" src="https://img.shields.io/github/license/Shinigami92/hsml.svg">
7
- </a>
8
- <a href="https://www.paypal.com/donate?hosted_button_id=L7GY729FBKTZY" target="_blank">
9
- <img alt="Donate: PayPal" src="https://img.shields.io/badge/Donate-PayPal-blue.svg">
10
- </a>
11
- </p>
1
+ [![Crate](https://img.shields.io/crates/v/hsml.svg)](https://crates.io/crates/hsml)
2
+ [![Downloads](https://img.shields.io/crates/d/hsml.svg)](https://crates.io/crates/hsml)
3
+ [![NPM](https://img.shields.io/npm/v/hsml.svg)](https://www.npmjs.com/package/hsml)
4
+ [![Downloads](https://img.shields.io/npm/dt/hsml.svg)](https://www.npmjs.com/package/hsml)
5
+ [![CI](https://github.com/hsml-lab/hsml/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/hsml-lab/hsml/actions/workflows/ci.yml)
6
+ [![codecov](https://codecov.io/gh/hsml-lab/hsml/branch/main/graph/badge.svg)](https://codecov.io/gh/hsml-lab/hsml)
7
+ [![License: MIT](https://img.shields.io/github/license/hsml-lab/hsml.svg)](https://github.com/hsml-lab/hsml/blob/main/LICENSE)
8
+ [![Donate: PayPal](https://img.shields.io/badge/Donate-PayPal-blue.svg)](https://www.paypal.com/donate?hosted_button_id=L7GY729FBKTZY)
12
9
 
13
- # UNDER CONSTRUCTION
10
+ # HSML - Hyper Short Markup Language
14
11
 
15
- Right now there is no usable version of `hsml` available. I'm just working on it.
12
+ A pug-inspired HTML preprocessor, written in Rust. Less typing, more shipping.
16
13
 
17
- <img src="https://chronicle-brightspot.s3.amazonaws.com/6a/c4/00e4ab3143f7e0cf4d9fd33aa00b/constructocat2.jpg" width="400px" />
14
+ > Still young and growing! Some features are cooking. Check out the [roadmap](#roadmap) below.
18
15
 
19
- # HSML - Hyper Short Markup Language
16
+ ## What is it?
20
17
 
21
- `hsml` is a hyper short markup language that is inspired by [pug](https://pugjs.org) (aka jade).
18
+ HSML compiles a short, indentation-based syntax into HTML think [Pug](https://pugjs.org), but leaner:
22
19
 
23
- ## What is it?
20
+ - **TailwindCSS-friendly** arbitrary values like `.bg-[#1da1f2]` and `lg:[&:nth-child(3)]:hover:underline` just work
21
+ - **No template engine** — HSML is to HTML what TypeScript is to JavaScript: a compile-time transformation, no runtime
22
+ - **Rust-powered** — fast native CLI + WASM package for browser and bundler use
23
+ - **Helpful diagnostics** — descriptive errors and warnings with source context, like a good compiler should
24
+
25
+ ## Quick taste
26
+
27
+ ```hsml
28
+ doctype html
29
+ html
30
+ head
31
+ title My Page
32
+ body
33
+ h1.text-xl.font-bold Hello World
34
+ .card
35
+ img.rounded-full(src="/avatar.jpg" alt="Me")
36
+ p.text-gray-500 Nice to meet you!
37
+ ```
38
+
39
+ Compiles to:
40
+
41
+ ```html
42
+ <!DOCTYPE html>
43
+ <html>
44
+ <head>
45
+ <title>My Page</title>
46
+ </head>
47
+ <body>
48
+ <h1 class="text-xl font-bold">Hello World</h1>
49
+ <div class="card">
50
+ <img class="rounded-full" src="/avatar.jpg" alt="Me" />
51
+ <p class="text-gray-500">Nice to meet you!</p>
52
+ </div>
53
+ </body>
54
+ </html>
55
+ ```
56
+
57
+ ## Installation
58
+
59
+ ### CLI (via Cargo)
60
+
61
+ ```sh
62
+ cargo install hsml
63
+ ```
64
+
65
+ ### WASM (via npm)
66
+
67
+ ```sh
68
+ npm install -D hsml
69
+ # or
70
+ pnpm add -D hsml
71
+ # or
72
+ bun add -D hsml
73
+ ```
74
+
75
+ ## Usage
76
+
77
+ ### CLI
78
+
79
+ ```sh
80
+ # Compile a single file
81
+ hsml compile index.hsml
82
+
83
+ # Compile to a specific output file
84
+ hsml compile index.hsml -o output.html
85
+
86
+ # Compile all .hsml files in a directory
87
+ hsml compile src/
88
+
89
+ # Get diagnostics as JSON (for CI integration)
90
+ hsml compile index.hsml --report-format json
91
+ ```
92
+
93
+ ### WASM / JavaScript
94
+
95
+ ```js
96
+ import { compileContent, compileContentWithDiagnostics } from "hsml";
97
+
98
+ // Simple compilation
99
+ const html = compileContent("h1.title Hello World\n");
100
+ // => '<h1 class="title">Hello World</h1>'
101
+
102
+ // With diagnostics (errors + warnings)
103
+ const result = compileContentWithDiagnostics("h1.foo.foo Hello\n");
104
+ // => { success: true, html: '...', diagnostics: [{ severity: 'warning', code: 'W002', ... }] }
105
+ ```
106
+
107
+ ## HSML Syntax
108
+
109
+ ### Tags
110
+
111
+ ```hsml
112
+ h1 Hello World
113
+ div
114
+ p Some text
115
+ ```
116
+
117
+ Tags default to `div` when only a class or id is specified:
118
+
119
+ ```hsml
120
+ .container
121
+ .card
122
+ .card-body Hello
123
+ ```
124
+
125
+ ### Classes
126
+
127
+ ```hsml
128
+ h1.text-red.font-bold Hello
129
+ ```
130
+
131
+ TailwindCSS arbitrary values are fully supported:
132
+
133
+ ```hsml
134
+ .bg-[#1da1f2].lg:[&:nth-child(3)]:hover:underline
135
+ ```
136
+
137
+ ### IDs
138
+
139
+ ```hsml
140
+ div#app
141
+ h1#title Hello
142
+ ```
143
+
144
+ ### Attributes
145
+
146
+ ```hsml
147
+ img(src="/photo.jpg" alt="A photo" width="300")
148
+ a(href="https://github.com" target="_blank") GitHub
149
+ button(disabled) Click me
150
+ ```
151
+
152
+ Multiline attributes work too:
153
+
154
+ ```hsml
155
+ img(
156
+ src="/photo.jpg"
157
+ alt="A photo"
158
+ width="300"
159
+ height="200"
160
+ )
161
+ ```
162
+
163
+ ### Text blocks
164
+
165
+ Use a trailing `.` to start a text block:
166
+
167
+ ```hsml
168
+ p.
169
+ This is a multi-line
170
+ text block that preserves
171
+ line breaks.
172
+ ```
173
+
174
+ ### Comments
175
+
176
+ ```hsml
177
+ // Dev comment (excluded from HTML output)
178
+ //! Native comment (rendered as <!-- ... -->)
179
+ ```
180
+
181
+ ### Doctype
182
+
183
+ ```hsml
184
+ doctype html
185
+ ```
186
+
187
+ ### Vue / Angular support
188
+
189
+ HSML supports framework-specific attribute syntax out of the box:
190
+
191
+ ```hsml
192
+ // Vue
193
+ button(@click="handleClick" :class="dynamicClass" v-if="show") Click
194
+ template(#default)
195
+ p Slot content
196
+
197
+ // Angular
198
+ button([disabled]="isDisabled" (click)="onClick()") Click
199
+ ```
200
+
201
+ ## Diagnostics
202
+
203
+ HSML provides helpful error messages with source context:
204
+
205
+ ```log
206
+ error[E001]: Tag name must start with an ASCII letter
207
+ --> example.hsml:1:1
208
+ |
209
+ 1 | 42div Hello
210
+ | ^
211
+ ```
212
+
213
+ And warnings for common mistakes:
214
+
215
+ ```log
216
+ warning[W002]: Duplicate class 'foo'
217
+ --> example.hsml:1:12
218
+ |
219
+ 1 | h1.foo.foo Hello
220
+ | ^
221
+ ```
222
+
223
+ ### Error & warning codes
224
+
225
+ | Code | Description |
226
+ | ---- | ---------------------------------------- |
227
+ | E001 | Tag name must start with an ASCII letter |
228
+ | E002 | Unclosed bracket |
229
+ | E003 | Unclosed parenthesis |
230
+ | E004 | Unclosed quote in attribute value |
231
+ | E005 | Expected quoted attribute value |
232
+ | E006 | Invalid attribute key |
233
+ | W001 | Duplicate id (only one per element) |
234
+ | W002 | Duplicate class |
235
+ | W003 | Mixed tabs and spaces in indentation |
236
+ | W004 | Duplicate attribute |
237
+
238
+ ## Roadmap
239
+
240
+ - [x] Parser with TailwindCSS support
241
+ - [x] HTML compiler
242
+ - [x] CLI with `compile` command
243
+ - [x] WASM package for npm
244
+ - [x] Diagnostic system with errors and warnings
245
+ - [x] JSON diagnostic output (`--report-format json`)
246
+ - [ ] `hsml check` — standalone linting command
247
+ - [ ] `hsml fmt` — code formatter
248
+ - [ ] `hsml parse` — AST output as JSON
249
+ - [ ] LSP server for editor integration
250
+ - [ ] GitHub/GitLab CI diagnostic formatters
251
+
252
+ ## Contributing
24
253
 
25
- - `hsml` is written in [Rust](https://www.rust-lang.org) and compiles to HTML.
26
- - There will be a binary that can take CLI arguments to compile a `.hsml` file to a `.html` file, but also there will be some other arguments to e.g. format a `.hsml` file.
27
- - There will be also a library that can parse a `.hsml` file and return an AST for it. It is planned that this AST can be used in the JS ecosystem as well, so tools like ESLint and Prettier can work with it.
28
- - There are two major differences between `pug` and `hsml`
29
- - `hsml` will support TailwindCSS and similar CSS frameworks out of the box, even with arbitrary values like `.bg-[#1da1f2]` or `lg:[&:nth-child(3)]:hover:underline`
30
- - `hsml` will **not** support template engine syntax. It is _just_ an HTML preprocessor.
254
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and commands.
31
255
 
32
- ## Why doing it?
256
+ ## License
33
257
 
34
- - I want to learn Rust
35
- - I use `pug` for my projects but sadly `pug`'s goal mismatches my preferences and comes with a lot of overhead I don't need
258
+ [MIT](LICENSE) go wild.
package/hsml.d.ts CHANGED
@@ -1,7 +1,35 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+
3
4
  /**
4
- * @param {string} source
5
- * @returns {string}
6
- */
7
- export function compile_content(source: string): string;
5
+ * Compile HSML source to HTML, exposed as a WASM binding.
6
+ *
7
+ * Returns the compiled HTML string, or a `JsError` on parse/compile failure.
8
+ */
9
+ export function compileContent(source: string): string;
10
+
11
+ /**
12
+ * Compile HSML source and return a JS object with HTML output and diagnostics.
13
+ *
14
+ * Returns a JS object: `{ success: boolean, html: string | null, diagnostics: Diagnostic[] }`
15
+ */
16
+ export function compileContentWithDiagnostics(source: string): CompileResult;
17
+
18
+ export interface Location {
19
+ line: number;
20
+ column: number;
21
+ }
22
+
23
+ export interface Diagnostic {
24
+ severity: "error" | "warning";
25
+ message: string;
26
+ code?: string;
27
+ location?: Location;
28
+ filePath?: string;
29
+ }
30
+
31
+ export interface CompileResult {
32
+ success: boolean;
33
+ html: string | null;
34
+ diagnostics: Diagnostic[];
35
+ }
package/hsml.js CHANGED
@@ -1,116 +1,9 @@
1
- let imports = {};
2
- let wasm;
3
- const { TextEncoder, TextDecoder } = require(`util`);
4
-
5
- let WASM_VECTOR_LEN = 0;
6
-
7
- let cachedUint8Memory0 = null;
8
-
9
- function getUint8Memory0() {
10
- if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
11
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
12
- }
13
- return cachedUint8Memory0;
14
- }
15
-
16
- let cachedTextEncoder = new TextEncoder('utf-8');
17
-
18
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
19
- ? function (arg, view) {
20
- return cachedTextEncoder.encodeInto(arg, view);
21
- }
22
- : function (arg, view) {
23
- const buf = cachedTextEncoder.encode(arg);
24
- view.set(buf);
25
- return {
26
- read: arg.length,
27
- written: buf.length
28
- };
29
- });
30
-
31
- function passStringToWasm0(arg, malloc, realloc) {
32
-
33
- if (realloc === undefined) {
34
- const buf = cachedTextEncoder.encode(arg);
35
- const ptr = malloc(buf.length) >>> 0;
36
- getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
37
- WASM_VECTOR_LEN = buf.length;
38
- return ptr;
39
- }
40
-
41
- let len = arg.length;
42
- let ptr = malloc(len) >>> 0;
43
-
44
- const mem = getUint8Memory0();
45
-
46
- let offset = 0;
47
-
48
- for (; offset < len; offset++) {
49
- const code = arg.charCodeAt(offset);
50
- if (code > 0x7F) break;
51
- mem[ptr + offset] = code;
52
- }
53
-
54
- if (offset !== len) {
55
- if (offset !== 0) {
56
- arg = arg.slice(offset);
57
- }
58
- ptr = realloc(ptr, len, len = offset + arg.length * 3) >>> 0;
59
- const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
60
- const ret = encodeString(arg, view);
61
-
62
- offset += ret.written;
63
- }
64
-
65
- WASM_VECTOR_LEN = offset;
66
- return ptr;
67
- }
68
-
69
- let cachedInt32Memory0 = null;
70
-
71
- function getInt32Memory0() {
72
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
73
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
74
- }
75
- return cachedInt32Memory0;
76
- }
77
-
78
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
79
-
80
- cachedTextDecoder.decode();
81
-
82
- function getStringFromWasm0(ptr, len) {
83
- ptr = ptr >>> 0;
84
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
85
- }
86
- /**
87
- * @param {string} source
88
- * @returns {string}
89
- */
90
- module.exports.compile_content = function(source) {
91
- let deferred2_0;
92
- let deferred2_1;
93
- try {
94
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
95
- const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
96
- const len0 = WASM_VECTOR_LEN;
97
- wasm.compile_content(retptr, ptr0, len0);
98
- var r0 = getInt32Memory0()[retptr / 4 + 0];
99
- var r1 = getInt32Memory0()[retptr / 4 + 1];
100
- deferred2_0 = r0;
101
- deferred2_1 = r1;
102
- return getStringFromWasm0(r0, r1);
103
- } finally {
104
- wasm.__wbindgen_add_to_stack_pointer(16);
105
- wasm.__wbindgen_free(deferred2_0, deferred2_1);
106
- }
107
- };
108
-
109
- const path = require('path').join(__dirname, 'hsml_bg.wasm');
110
- const bytes = require('fs').readFileSync(path);
111
-
112
- const wasmModule = new WebAssembly.Module(bytes);
113
- const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
114
- wasm = wasmInstance.exports;
115
- module.exports.__wasm = wasm;
116
-
1
+ /* @ts-self-types="./hsml.d.ts" */
2
+
3
+ import * as wasm from "./hsml_bg.wasm";
4
+ import { __wbg_set_wasm } from "./hsml_bg.js";
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ compileContent, compileContentWithDiagnostics
9
+ } from "./hsml_bg.js";
package/hsml_bg.js ADDED
@@ -0,0 +1,258 @@
1
+ /**
2
+ * Compile HSML source to HTML, exposed as a WASM binding.
3
+ *
4
+ * Returns the compiled HTML string, or a `JsError` on parse/compile failure.
5
+ * @param {string} source
6
+ * @returns {string}
7
+ */
8
+ export function compileContent(source) {
9
+ let deferred3_0;
10
+ let deferred3_1;
11
+ try {
12
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
13
+ const len0 = WASM_VECTOR_LEN;
14
+ const ret = wasm.compileContent(ptr0, len0);
15
+ var ptr2 = ret[0];
16
+ var len2 = ret[1];
17
+ if (ret[3]) {
18
+ ptr2 = 0; len2 = 0;
19
+ throw takeFromExternrefTable0(ret[2]);
20
+ }
21
+ deferred3_0 = ptr2;
22
+ deferred3_1 = len2;
23
+ return getStringFromWasm0(ptr2, len2);
24
+ } finally {
25
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
26
+ }
27
+ }
28
+
29
+ /**
30
+ * Compile HSML source and return a JS object with HTML output and diagnostics.
31
+ *
32
+ * Returns a JS object: `{ success: boolean, html: string | null, diagnostics: Diagnostic[] }`
33
+ * @param {string} source
34
+ * @returns {any}
35
+ */
36
+ export function compileContentWithDiagnostics(source) {
37
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
38
+ const len0 = WASM_VECTOR_LEN;
39
+ const ret = wasm.compileContentWithDiagnostics(ptr0, len0);
40
+ return ret;
41
+ }
42
+ export function __wbg_Error_83742b46f01ce22d(arg0, arg1) {
43
+ const ret = Error(getStringFromWasm0(arg0, arg1));
44
+ return ret;
45
+ }
46
+ export function __wbg_String_8564e559799eccda(arg0, arg1) {
47
+ const ret = String(arg1);
48
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
49
+ const len1 = WASM_VECTOR_LEN;
50
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
51
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
52
+ }
53
+ export function __wbg___wbindgen_debug_string_5398f5bb970e0daa(arg0, arg1) {
54
+ const ret = debugString(arg1);
55
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
56
+ const len1 = WASM_VECTOR_LEN;
57
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
58
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
59
+ }
60
+ export function __wbg___wbindgen_throw_6ddd609b62940d55(arg0, arg1) {
61
+ throw new Error(getStringFromWasm0(arg0, arg1));
62
+ }
63
+ export function __wbg_new_a70fbab9066b301f() {
64
+ const ret = new Array();
65
+ return ret;
66
+ }
67
+ export function __wbg_new_ab79df5bd7c26067() {
68
+ const ret = new Object();
69
+ return ret;
70
+ }
71
+ export function __wbg_set_282384002438957f(arg0, arg1, arg2) {
72
+ arg0[arg1 >>> 0] = arg2;
73
+ }
74
+ export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
75
+ arg0[arg1] = arg2;
76
+ }
77
+ export function __wbindgen_cast_0000000000000001(arg0) {
78
+ // Cast intrinsic for `F64 -> Externref`.
79
+ const ret = arg0;
80
+ return ret;
81
+ }
82
+ export function __wbindgen_cast_0000000000000002(arg0, arg1) {
83
+ // Cast intrinsic for `Ref(String) -> Externref`.
84
+ const ret = getStringFromWasm0(arg0, arg1);
85
+ return ret;
86
+ }
87
+ export function __wbindgen_init_externref_table() {
88
+ const table = wasm.__wbindgen_externrefs;
89
+ const offset = table.grow(4);
90
+ table.set(0, undefined);
91
+ table.set(offset + 0, undefined);
92
+ table.set(offset + 1, null);
93
+ table.set(offset + 2, true);
94
+ table.set(offset + 3, false);
95
+ }
96
+ function debugString(val) {
97
+ // primitive types
98
+ const type = typeof val;
99
+ if (type == 'number' || type == 'boolean' || val == null) {
100
+ return `${val}`;
101
+ }
102
+ if (type == 'string') {
103
+ return `"${val}"`;
104
+ }
105
+ if (type == 'symbol') {
106
+ const description = val.description;
107
+ if (description == null) {
108
+ return 'Symbol';
109
+ } else {
110
+ return `Symbol(${description})`;
111
+ }
112
+ }
113
+ if (type == 'function') {
114
+ const name = val.name;
115
+ if (typeof name == 'string' && name.length > 0) {
116
+ return `Function(${name})`;
117
+ } else {
118
+ return 'Function';
119
+ }
120
+ }
121
+ // objects
122
+ if (Array.isArray(val)) {
123
+ const length = val.length;
124
+ let debug = '[';
125
+ if (length > 0) {
126
+ debug += debugString(val[0]);
127
+ }
128
+ for(let i = 1; i < length; i++) {
129
+ debug += ', ' + debugString(val[i]);
130
+ }
131
+ debug += ']';
132
+ return debug;
133
+ }
134
+ // Test for built-in
135
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
136
+ let className;
137
+ if (builtInMatches && builtInMatches.length > 1) {
138
+ className = builtInMatches[1];
139
+ } else {
140
+ // Failed to match the standard '[object ClassName]'
141
+ return toString.call(val);
142
+ }
143
+ if (className == 'Object') {
144
+ // we're a user defined class or Object
145
+ // JSON.stringify avoids problems with cycles, and is generally much
146
+ // easier than looping through ownProperties of `val`.
147
+ try {
148
+ return 'Object(' + JSON.stringify(val) + ')';
149
+ } catch (_) {
150
+ return 'Object';
151
+ }
152
+ }
153
+ // errors
154
+ if (val instanceof Error) {
155
+ return `${val.name}: ${val.message}\n${val.stack}`;
156
+ }
157
+ // TODO we could test for more things here, like `Set`s and `Map`s.
158
+ return className;
159
+ }
160
+
161
+ let cachedDataViewMemory0 = null;
162
+ function getDataViewMemory0() {
163
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
164
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
165
+ }
166
+ return cachedDataViewMemory0;
167
+ }
168
+
169
+ function getStringFromWasm0(ptr, len) {
170
+ ptr = ptr >>> 0;
171
+ return decodeText(ptr, len);
172
+ }
173
+
174
+ let cachedUint8ArrayMemory0 = null;
175
+ function getUint8ArrayMemory0() {
176
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
177
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
178
+ }
179
+ return cachedUint8ArrayMemory0;
180
+ }
181
+
182
+ function passStringToWasm0(arg, malloc, realloc) {
183
+ if (realloc === undefined) {
184
+ const buf = cachedTextEncoder.encode(arg);
185
+ const ptr = malloc(buf.length, 1) >>> 0;
186
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
187
+ WASM_VECTOR_LEN = buf.length;
188
+ return ptr;
189
+ }
190
+
191
+ let len = arg.length;
192
+ let ptr = malloc(len, 1) >>> 0;
193
+
194
+ const mem = getUint8ArrayMemory0();
195
+
196
+ let offset = 0;
197
+
198
+ for (; offset < len; offset++) {
199
+ const code = arg.charCodeAt(offset);
200
+ if (code > 0x7F) break;
201
+ mem[ptr + offset] = code;
202
+ }
203
+ if (offset !== len) {
204
+ if (offset !== 0) {
205
+ arg = arg.slice(offset);
206
+ }
207
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
208
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
209
+ const ret = cachedTextEncoder.encodeInto(arg, view);
210
+
211
+ offset += ret.written;
212
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
213
+ }
214
+
215
+ WASM_VECTOR_LEN = offset;
216
+ return ptr;
217
+ }
218
+
219
+ function takeFromExternrefTable0(idx) {
220
+ const value = wasm.__wbindgen_externrefs.get(idx);
221
+ wasm.__externref_table_dealloc(idx);
222
+ return value;
223
+ }
224
+
225
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
226
+ cachedTextDecoder.decode();
227
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
228
+ let numBytesDecoded = 0;
229
+ function decodeText(ptr, len) {
230
+ numBytesDecoded += len;
231
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
232
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
233
+ cachedTextDecoder.decode();
234
+ numBytesDecoded = len;
235
+ }
236
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
237
+ }
238
+
239
+ const cachedTextEncoder = new TextEncoder();
240
+
241
+ if (!('encodeInto' in cachedTextEncoder)) {
242
+ cachedTextEncoder.encodeInto = function (arg, view) {
243
+ const buf = cachedTextEncoder.encode(arg);
244
+ view.set(buf);
245
+ return {
246
+ read: arg.length,
247
+ written: buf.length
248
+ };
249
+ };
250
+ }
251
+
252
+ let WASM_VECTOR_LEN = 0;
253
+
254
+
255
+ let wasm;
256
+ export function __wbg_set_wasm(val) {
257
+ wasm = val;
258
+ }
package/hsml_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,25 +1,33 @@
1
1
  {
2
2
  "name": "hsml",
3
+ "type": "module",
3
4
  "collaborators": [
4
5
  "Christopher Quadflieg <chrissi92@hotmail.de>"
5
6
  ],
6
7
  "description": "A pug-inspired HTML preprocessor",
7
- "version": "0.1.0",
8
+ "version": "0.2.0",
8
9
  "license": "MIT",
9
10
  "repository": {
10
11
  "type": "git",
11
- "url": "https://github.com/Shinigami92/hsml"
12
+ "url": "https://github.com/hsml-lab/hsml"
12
13
  },
13
14
  "files": [
14
15
  "hsml_bg.wasm",
15
16
  "hsml.js",
17
+ "hsml_bg.js",
16
18
  "hsml.d.ts"
17
19
  ],
18
20
  "main": "hsml.js",
21
+ "homepage": "https://github.com/hsml-lab/hsml",
19
22
  "types": "hsml.d.ts",
23
+ "sideEffects": [
24
+ "./hsml.js",
25
+ "./snippets/*"
26
+ ],
20
27
  "keywords": [
21
28
  "hsml",
22
29
  "html",
23
- "preprocessor"
30
+ "preprocessor",
31
+ "wasm"
24
32
  ]
25
33
  }