fratmscript 0.10.2 → 0.12.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/index.d.ts +12 -0
- package/index.js +1 -1
- package/lib/api.js +8 -1
- package/package.json +1 -1
- package/wasm/node/fratm_wasm.js +27 -0
- package/wasm/node/fratm_wasm_bg.wasm +0 -0
- package/wasm/web/fratm_wasm.js +26 -0
- package/wasm/web/fratm_wasm_bg.wasm +0 -0
package/index.d.ts
CHANGED
|
@@ -55,3 +55,15 @@ export function version(): string;
|
|
|
55
55
|
* their message.
|
|
56
56
|
*/
|
|
57
57
|
export function runtimeError(error: unknown): string;
|
|
58
|
+
|
|
59
|
+
export interface ScaffoldOptions {
|
|
60
|
+
/** `react` (default), `completa` (React + API + SQLite), `senza-react` or `semplice` */
|
|
61
|
+
template?: 'react' | 'completa' | 'senza-react' | 'semplice';
|
|
62
|
+
/** Folder name, which becomes the package name */
|
|
63
|
+
name?: string;
|
|
64
|
+
/** Adds Tailwind CSS to the React templates */
|
|
65
|
+
tailwind?: boolean;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The files of a new project, like `fratm nuovo` (used by `npm create fratm`). */
|
|
69
|
+
export function scaffold(options?: ScaffoldOptions): { path: string; contents: string }[];
|
package/index.js
CHANGED
|
@@ -4,4 +4,4 @@ import { createApi } from './lib/api.js';
|
|
|
4
4
|
|
|
5
5
|
const wasm = createRequire(import.meta.url)('./wasm/node/fratm_wasm.js');
|
|
6
6
|
|
|
7
|
-
export const { compile, format, version, runtimeError } = createApi(wasm);
|
|
7
|
+
export const { compile, format, version, runtimeError, scaffold } = createApi(wasm);
|
package/lib/api.js
CHANGED
|
@@ -47,5 +47,12 @@ export function createApi(wasm) {
|
|
|
47
47
|
return wasm.runtimeError(name, message);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
function scaffold(options = {}) {
|
|
51
|
+
const { template = 'react', name = 'app', tailwind = false } = options;
|
|
52
|
+
const files = JSON.parse(wasm.scaffold(String(template), String(name), Boolean(tailwind)));
|
|
53
|
+
if (files === null) throw new Error(`Unknown template '${template}'`);
|
|
54
|
+
return files;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return { compile, format, version, runtimeError, scaffold };
|
|
51
58
|
}
|
package/package.json
CHANGED
package/wasm/node/fratm_wasm.js
CHANGED
|
@@ -99,6 +99,33 @@ function runtimeError(name, message) {
|
|
|
99
99
|
}
|
|
100
100
|
exports.runtimeError = runtimeError;
|
|
101
101
|
|
|
102
|
+
/**
|
|
103
|
+
* The files of a new project, like `fratm nuovo`, as a JSON string:
|
|
104
|
+
* `[{ path, contents }]`, or `null` for an unknown template (`react`,
|
|
105
|
+
* `completa`, `senza-react`, `semplice`). Used by `npm create fratm`.
|
|
106
|
+
* @param {string} template
|
|
107
|
+
* @param {string} folder
|
|
108
|
+
* @param {boolean} tailwind
|
|
109
|
+
* @returns {string}
|
|
110
|
+
*/
|
|
111
|
+
function scaffold(template, folder, tailwind) {
|
|
112
|
+
let deferred3_0;
|
|
113
|
+
let deferred3_1;
|
|
114
|
+
try {
|
|
115
|
+
const ptr0 = passStringToWasm0(template, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
116
|
+
const len0 = WASM_VECTOR_LEN;
|
|
117
|
+
const ptr1 = passStringToWasm0(folder, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
118
|
+
const len1 = WASM_VECTOR_LEN;
|
|
119
|
+
const ret = wasm.scaffold(ptr0, len0, ptr1, len1, tailwind);
|
|
120
|
+
deferred3_0 = ret[0];
|
|
121
|
+
deferred3_1 = ret[1];
|
|
122
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
123
|
+
} finally {
|
|
124
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.scaffold = scaffold;
|
|
128
|
+
|
|
102
129
|
/**
|
|
103
130
|
* Tokenize source code (for syntax highlighting)
|
|
104
131
|
* @param {string} source
|
|
Binary file
|
package/wasm/web/fratm_wasm.js
CHANGED
|
@@ -94,6 +94,32 @@ export function runtimeError(name, message) {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
/**
|
|
98
|
+
* The files of a new project, like `fratm nuovo`, as a JSON string:
|
|
99
|
+
* `[{ path, contents }]`, or `null` for an unknown template (`react`,
|
|
100
|
+
* `completa`, `senza-react`, `semplice`). Used by `npm create fratm`.
|
|
101
|
+
* @param {string} template
|
|
102
|
+
* @param {string} folder
|
|
103
|
+
* @param {boolean} tailwind
|
|
104
|
+
* @returns {string}
|
|
105
|
+
*/
|
|
106
|
+
export function scaffold(template, folder, tailwind) {
|
|
107
|
+
let deferred3_0;
|
|
108
|
+
let deferred3_1;
|
|
109
|
+
try {
|
|
110
|
+
const ptr0 = passStringToWasm0(template, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
111
|
+
const len0 = WASM_VECTOR_LEN;
|
|
112
|
+
const ptr1 = passStringToWasm0(folder, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
113
|
+
const len1 = WASM_VECTOR_LEN;
|
|
114
|
+
const ret = wasm.scaffold(ptr0, len0, ptr1, len1, tailwind);
|
|
115
|
+
deferred3_0 = ret[0];
|
|
116
|
+
deferred3_1 = ret[1];
|
|
117
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
118
|
+
} finally {
|
|
119
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
97
123
|
/**
|
|
98
124
|
* Tokenize source code (for syntax highlighting)
|
|
99
125
|
* @param {string} source
|
|
Binary file
|