@makano/rew 1.2.47 → 1.2.52

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/jsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "checkJs": true,
4
+ "lib": ["ESNext"],
5
+ "module": "Node16"
6
+ },
7
+ "include": [
8
+ "./runtime.d.ts"
9
+ ],
10
+ "typeAcquisition": {
11
+ "include": ["./runtime.d.ts"]
12
+ }
13
+ }
@@ -126,6 +126,10 @@ module.exports = {
126
126
  fs.writeFileSync(path.join(projectPath, '.gitignore'), `node_modules/\npackage-lock.json`);
127
127
  execSync('cd ' + projectPath + ' && git init . && git branch -m main', { stdio: 'ignore' });
128
128
  }
129
+ if(project.intellisense){
130
+ fs.copyFileSync(path.join(__dirname, '../../../jsconfig.json'), path.join(projectPath, 'jsconfig.json'));
131
+ fs.copyFileSync(path.join(__dirname, '../../../runtime.d.ts'), path.join(projectPath, 'runtime.d.ts'));
132
+ }
129
133
  execSync('cd ' + projectPath + ' && npm init -y', { stdio: 'ignore' });
130
134
  // log('Installing '+npm_package_name);
131
135
  // exec('cd '+projectPath+' && npm i '+npm_package_name, (err) => {
@@ -143,9 +147,12 @@ module.exports = {
143
147
  rl.question(logget(' Package Name: '.blue), (pkg) => {
144
148
  if (pkg.trim()) {
145
149
  project.package = pkg.trim();
146
- rl.question(logget('󰊢 Use git(y/N): '.yellow.bold), (use_git) => {
147
- project.git = use_git.toLowerCase() == 'y' || use_git.toLowerCase() == 'yes';
148
- create();
150
+ rl.question(logget(' Use intellisense declarations ? (y/N): '.magenta.bold), (inteli) => {
151
+ project.intellisense = inteli.toLowerCase() == 'y' || inteli.toLowerCase() == 'yes';
152
+ rl.question(logget('󰊢 Use git ? (y/N): '.yellow.bold), (use_git) => {
153
+ project.git = use_git.toLowerCase() == 'y' || use_git.toLowerCase() == 'yes';
154
+ create();
155
+ });
149
156
  });
150
157
  } else {
151
158
  rl.close();
@@ -1,6 +1,6 @@
1
1
  const execOptions = {
2
2
  sharedContext: true,
3
- resolveExtensions: [{ ext: '.js', options: { type: 'js' } }, { ext: '.qrew', options: { qrew: true } }, '.coffee'],
3
+ resolveExtensions: ['.coffee', { ext: '.js', options: { type: 'js' } }, { ext: '.qrew', options: { qrew: true } }],
4
4
  nativeRequire: false,
5
5
  cwdAlias: '$',
6
6
  jsxPragma: 'createElement',
@@ -43,8 +43,6 @@ module.exports.imp = function (runPath, context) {
43
43
  let filepath = path.resolve(path.dirname(context.module.filepath), filename);
44
44
  if(path.extname(filepath) == '.qrew') options.qrew = true;
45
45
 
46
- // console.log(typeof runPath);
47
-
48
46
  const lookUp = () => {
49
47
  const otherPath = lookUpInOtherApps(filename);
50
48
  if (!otherPath) throw new Error('Module "' + filename + '" not found');
@@ -57,7 +55,7 @@ module.exports.imp = function (runPath, context) {
57
55
  exports = foundCache.exports;
58
56
  }
59
57
 
60
- if (!ispkg && !existsSync(filepath)) {
58
+ if (!ispkg && !existsSync(filepath) && !foundCache) {
61
59
  if (Array.isArray(execOptions.resolveExtensions) && execOptions.resolveExtensions.length) {
62
60
  const resolve = execOptions.resolveExtensions.find((ext) =>
63
61
  typeof ext == 'string' ? existsSync(filepath + ext) : existsSync(filepath + (ext.ext || '')),
@@ -119,8 +117,24 @@ module.exports.imp = function (runPath, context) {
119
117
  }
120
118
  }
121
119
 
122
- if (!ispkg) context.module.imports.push(filepath);
123
- if (!ispkg) cachedFiles.push({ filepath, exports });
120
+ // Hehe, i just had an idea for a
121
+ // descriptive code
122
+ // you put them in comment blocks
123
+ // and name it something
124
+ // then you can simple see
125
+ // which part of a code contains a certain
126
+ // task. cool right?
127
+
128
+ //** If is not package, post exec section
129
+ /**/ if (!ispkg) context.module.imports.push(filepath);
130
+ /**/ if (!ispkg) cachedFiles.push({ filepath, exports });
131
+ //**
132
+
133
+ //** Mock imports section
134
+ /**/ if(!exports) exports = options.mock;
135
+ /**/ if(options.mock === null) return null;
136
+ /**/ if(!exports) throw new Error('Import '+filename+' does not export anything. Use the "mock" option to mock a value.');
137
+ //**
124
138
 
125
139
  return exports;
126
140
  };
@@ -154,6 +154,10 @@ function compileRewStuff(content, options) {
154
154
  });
155
155
  }
156
156
 
157
+ if (token.type === 'IDENTIFIER' && token.value === 'export') {
158
+ token.value = 'pub';
159
+ }
160
+
157
161
  if (token.type === 'IDENTIFIER' && token.value === 'import') {
158
162
  // console.log(nextToken.type);
159
163
  let ind = i + n + 2;
@@ -222,9 +226,16 @@ function compileRewStuff(content, options) {
222
226
  nextToken.value &&
223
227
  nextToken.value !== 'undefined'
224
228
  ) {
229
+ let next = {...nextToken};
230
+ if(next.value == 'default'){
231
+ i += 2;
232
+ }
233
+ if(next.value == 'class'){
234
+ next.value = gnextToken(i, n + 1, tokens)?.token.value || "default";
235
+ }
225
236
  hooks.push({
226
237
  index: i + 1,
227
- value: `"${nextToken.value}", `,
238
+ value: `"${next.value}", `,
228
239
  });
229
240
  }
230
241
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.2.47",
3
+ "version": "1.2.52",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {
@@ -11,6 +11,8 @@
11
11
  },
12
12
  "files": [
13
13
  "lib/",
14
+ "runtime.d.ts",
15
+ "jsconfig.json",
14
16
  "main.js",
15
17
  "README.md"
16
18
  ],
package/runtime.d.ts ADDED
@@ -0,0 +1,374 @@
1
+
2
+ interface ImportOptions {
3
+ /**
4
+ * Determines how to import the given module
5
+ */
6
+ type: 'js' | 'coffee' | 'yaml' | 'json' | 'qrew';
7
+ [key: string]: any;
8
+ }
9
+
10
+ interface ModuleConfOptionCenter {
11
+ /**
12
+ * Get a config key
13
+ * @param key The key of the config to get
14
+ * @param defaultValue The default value ig null
15
+ * @returns The value of the key or the defaultValue if it's null.
16
+ */
17
+ get: <T = any>(key: string, defaultValue?: T) => T
18
+ /**
19
+ * Set a config key
20
+ * @param key The key of the config to set
21
+ * @param value The value to set it to
22
+ * @returns true if it was a success
23
+ */
24
+ set: <T = any>(key: string, value: T) => boolean
25
+ /**
26
+ * Removes a key from the config
27
+ * @param key The key of the config to remove
28
+ * @returns true if it was a success
29
+ */
30
+ remove: (key: string) => boolean
31
+ /**
32
+ * Resets the entire config option center to it's default value
33
+ */
34
+ reset: () => boolean
35
+ /**
36
+ * Get all values in an option center
37
+ * @param str
38
+ * @returns
39
+ */
40
+ getAll: (() => string) | ((str?: false) => Record<string, any>)
41
+ }
42
+
43
+ interface ModuleConf extends ModuleConfOptionCenter {
44
+ /**
45
+ * A separate options file for a related set of options
46
+ * @param name The option center full path
47
+ * @param defaults The default values
48
+ *
49
+ * @example
50
+ * conf = imp 'conf'
51
+ *
52
+ * animations = conf.optionCenter 'animations', enable: false, speed: '1x'
53
+ *
54
+ * if animations.get 'enable'
55
+ * animate animations.get 'speed'
56
+ */
57
+ optionCenter: (name: string, defaults?: any) => ModuleConfOptionCenter;
58
+ /**
59
+ * Manage Static files
60
+ */
61
+ staticFile: (name: string, defaults?: any) => {
62
+ write: (value: any, ifExists?: boolean) => this,
63
+ read: (to?: string | object) => string | object | Buffer,
64
+ fileRoot: string,
65
+ exists: boolean
66
+ }
67
+ }
68
+
69
+ interface ModuleEnv {
70
+ has: (key: string) => boolean,
71
+ get: (key: string) => string,
72
+ set: (key: string, value: string) => boolean,
73
+ rm: (key: string) => boolean,
74
+ is: (key: string, value: string) => boolean,
75
+ }
76
+
77
+ interface ModuleRuneDBCollcetion {
78
+ insert(record: object): any;
79
+ read(id: string | object, evaluate?: boolean): any;
80
+ update(caseRecord: string | object, newRecord: object): any;
81
+ remove(id: string | object): boolean;
82
+ find(criteria: string | object): any;
83
+ map(cb: (data: any[]) => any[], mutate?: boolean): any[];
84
+ transform(cb: (data: any[]) => any[], mutate?: boolean): any[];
85
+ filter(cb: (data: any[]) => boolean, mutate?: boolean): any[];
86
+ sort(cb: (a: any, b: any) => number, mutate?: boolean): any[];
87
+ list(): any[];
88
+ }
89
+
90
+ interface ModuleRuneDBMap {
91
+ set(key: string, value: any): void;
92
+ get(key: string): any | null;
93
+ remove(key: string): boolean;
94
+ transform(cb: (data: any) => any, mutate?: boolean): any;
95
+ list(): { [key: string]: any };
96
+ }
97
+
98
+ interface ModuleRuneDB {
99
+ collection: (name: string) => ModuleRuneDBCollcetion
100
+ map: (name: string) => ModuleRuneDBMap
101
+ findRef: (ref: string) => any
102
+ setData: (data: Record<string, any>) => void
103
+ getData: () => Record<string, any>
104
+ makeRef(value: object, props?: string): string | null;
105
+ }
106
+
107
+ interface ModuleRune {
108
+ db(dbname: string, data?: object, encryptionKey?: string): ModuleRuneDB;
109
+ genKey(secret: string): string;
110
+ push(...values: any[]): PushChange;
111
+ pop(...values: any[]): PopChange;
112
+ }
113
+
114
+ interface ModuleThreads {
115
+ thread: (cb: Function) => {
116
+ stopAll: () => void
117
+ start: (context: Record<string, any>) => {
118
+ on: (event: string, callback: (data) => void) => void;
119
+ off: (event: string, callback: (data) => void) => void;
120
+ emit: (event: string, data: any) => void;
121
+ get: () => Promise,
122
+ stop: () => void
123
+ }
124
+ }
125
+ }
126
+
127
+ declare function imp(path: "conf", options?: ImportOptions): ModuleConf;
128
+ declare function imp(path: "env", options?: ImportOptions): ModuleEnv;
129
+ declare function imp(path: "rune", options?: ImportOptions): ModuleRune;
130
+ declare function imp(path: "threads", options?: ImportOptions): ModuleThreads;
131
+ declare function imp(path: string, options?: ImportOptions): any;
132
+
133
+ declare const inc = imp;
134
+
135
+ declare function require(moduleName: string): any;
136
+
137
+ interface Module {
138
+ exports: any;
139
+ filepath: string;
140
+ main: boolean;
141
+ impots: string[];
142
+ compiled: string
143
+ }
144
+
145
+ declare const module: Module;
146
+
147
+ interface Imports {
148
+ meta: {},
149
+ assets: any
150
+ }
151
+
152
+ declare const imports: Imports;
153
+
154
+ declare const process: {
155
+ argv: string[],
156
+ target: ReturnType<typeof emitter>,
157
+ __execFile: string,
158
+ env: Record<string, any>,
159
+ cwd: () => string,
160
+ arch: string,
161
+ exit: () => void
162
+ };
163
+
164
+ interface AppConfig {
165
+ manifest: {
166
+ package: string
167
+ }
168
+ }
169
+
170
+ declare const app: {
171
+ path: string,
172
+ config: AppConfig
173
+ }
174
+
175
+
176
+ declare function read(filepath: string, options?: { encoding: string }): string;
177
+
178
+ declare function realpath(filepath: string, options?: { encoding: string }): string;
179
+
180
+ declare function write(filepath: string, content: any, options?: any): void;
181
+
182
+ declare function exists(filepath: string, options?: any): boolean;
183
+
184
+ declare function fstat(filepath: string, options?: any): any;
185
+
186
+ declare function rm(filepath: string, options?: any): void;
187
+
188
+ declare function chmod(filepath: string, mode: any, options?: any): void;
189
+
190
+ declare function mkdir(filepath: string, options?: any): void;
191
+
192
+ declare function ls(filepath: string, options?: any): string[];
193
+
194
+ declare function struct(template: { [key: string]: any }): (...args: any[]) => any;
195
+
196
+ declare function future(callback: (resolve: (data: any) => void, reject: (data: any) => void) => void, timeout?: number, defData?: any): {
197
+ pipe(callback: (data: any) => any): Promise<any>;
198
+ last(callback: (data: any) => any): Promise<any>;
199
+ catch(callback: (data: any) => any): Promise<any>;
200
+ resolve(data: any): void;
201
+ reject(data: any): void;
202
+ wait(): Promise<any>;
203
+ };
204
+ declare namespace future {
205
+ function promise(promse: Promise<any>, timeout?: number, defData?: any): ReturnType<typeof future>;
206
+ }
207
+
208
+ declare function emitter(): {
209
+ on(event: string | string[], callback: (...args: any[]) => void, props?: {}): ReturnType<typeof emitter>;
210
+ off(event: string | string[], callback: (...args: any[]) => void, removable?: (event: any) => void): ReturnType<typeof emitter>;
211
+ emit(event: string | string[], ...data: any[]): ReturnType<typeof emitter>;
212
+ };
213
+ declare function exec(command: string, options?: { output?: boolean }): any;
214
+ declare namespace exec {
215
+ function background(command: string, options?: any, callback?: (...args: any[]) => void): any;
216
+ }
217
+ declare function spawn(command: string, ...args: any[]): any;
218
+
219
+ declare function typedef(value: any, strict?: boolean): { strict: boolean; defaultValue: any; class: Function; type: string; isConstucted: boolean; isEmpty: boolean };
220
+
221
+ declare function typeis(obj: any, typeDef: any): boolean;
222
+
223
+ declare function typex(child: any, parent: any): boolean;
224
+
225
+ declare function typei(child: any, parent: any): boolean;
226
+
227
+ declare function int(str: string): number;
228
+
229
+ declare namespace int {
230
+ const type: { strict: boolean; defaultValue: number; class: Function; type: string; isConstucted: boolean; isEmpty: boolean };
231
+ }
232
+ declare function float(str: string): number;
233
+ declare namespace float {
234
+ const type: { strict: boolean; defaultValue: number; class: Function; type: string; isConstucted: boolean; isEmpty: boolean };
235
+ }
236
+ declare function num(str: string): number;
237
+ declare namespace num {
238
+ const type: { strict: boolean; defaultValue: number; class: Function; type: string; isConstucted: boolean; isEmpty: boolean };
239
+ }
240
+ declare function str(str: any): string;
241
+ declare namespace str {
242
+ const type: { strict: boolean; defaultValue: string; class: Function; type: string; isConstucted: boolean; isEmpty: boolean };
243
+ }
244
+ declare function bool(value: any): boolean;
245
+ declare namespace bool {
246
+ const type: { strict: boolean; defaultValue: boolean; class: Function; type: string; isConstucted: boolean; isEmpty: boolean };
247
+ }
248
+ declare function isEmpty(value: any): boolean;
249
+ declare function clone(value: any): any;
250
+ declare function deepClone(value: any): any;
251
+ declare function merge(obj1: any, obj2: any): any;
252
+ declare const uniqueId: () => string;
253
+ declare function filter(arr: any[], fn: (value: any) => boolean): any[];
254
+ declare function reduce(arr: any[], fn: (acc: any, value: any) => any, initial: any): any;
255
+ declare function compose(...fns: Function[]): (initialValue: any) => any;
256
+ declare function curry(fn: Function): (...args: any[]) => any;
257
+ declare function json(thing: string): any;
258
+ declare function jsons(thing: any): string;
259
+ declare function yaml(thing: any): any;
260
+ declare function yamls(thing: any): string;
261
+
262
+
263
+ /**
264
+ * Makes a HTTP request to the specified URL.
265
+ * @param url The URL to request.
266
+ * @param options The options for the request.
267
+ * @returns A promise resolving to the response or other specified output based on the options.
268
+ */
269
+ declare function curl(url: string, options: {
270
+ /**
271
+ * Indicates whether to return a promise.
272
+ */
273
+ a: true,
274
+ /**
275
+ * Indicates whether to return the response as plain text.
276
+ */
277
+ text: true,
278
+ o?: string
279
+ }): Promise<string>;
280
+ /**
281
+ * Makes a HTTP request to the specified URL.
282
+ * @param url The URL to request.
283
+ * @param options The options for the request.
284
+ * @returns A promise resolving to the response or other specified output based on the options.
285
+ */
286
+ declare function curl(url: string, options: {
287
+ /**
288
+ * Indicates whether to return a promise.
289
+ */
290
+ a: true,
291
+ /**
292
+ * Indicates whether to return the response as JSON.
293
+ */
294
+ json: true,
295
+ /**
296
+ * The file path to output the response.
297
+ */
298
+ o?: string
299
+ }): Promise<object>;
300
+ /**
301
+ * Makes a HTTP request to the specified URL.
302
+ * @param url The URL to request.
303
+ * @param options The options for the request.
304
+ * @returns A promise resolving to the response or other specified output based on the options.
305
+ */
306
+ declare function curl(url: string, options: {
307
+ /**
308
+ * Indicates whether to return a promise.
309
+ */
310
+ a: true,
311
+ /**
312
+ * The file path to output the response.
313
+ */
314
+ o?: string
315
+ }): Promise<Response>;
316
+
317
+ /**
318
+ * Makes a HTTP request to the specified URL.
319
+ * @param url The URL to request.
320
+ * @param options The options for the request.
321
+ * @returns A promise resolving to the response or other specified output based on the options.
322
+ */
323
+ declare function curl(url: string, options?: {
324
+ /**
325
+ * Indicates whether to return a promise.
326
+ */
327
+ a?: boolean,
328
+ /**
329
+ * The file path to output the response.
330
+ */
331
+ o?: string,
332
+ /**
333
+ * Indicates whether to return the response as JSON.
334
+ */
335
+ json?: boolean,
336
+ /**
337
+ * Indicates whether to return the response as plain text.
338
+ */
339
+ text?: boolean
340
+ }): ReturnType<typeof future>;
341
+
342
+
343
+
344
+
345
+ declare function print(...args: any[]): void;
346
+ declare namespace print {
347
+ const stdout: WriteStream;
348
+ const stdin: ReadStream;
349
+ };
350
+
351
+ declare function input(prompt: string): string;
352
+
353
+
354
+ declare const basename: (path: string) => string;
355
+ declare const dirname: (path: string) => string;
356
+ declare const extname: (path: string) => string;
357
+ declare const pjoin: (...paths: string[]) => string;
358
+ declare const presolve: (...paths: string[]) => string;
359
+
360
+ declare function exports(value: any) : any;
361
+
362
+ declare function clear() : void;
363
+
364
+
365
+ declare function pub(value: any) : any;
366
+ declare function pub(name: string, value: any) : any;
367
+
368
+ declare const opt: {
369
+ set: (key: string, value: any) => void;
370
+ get: (key: string) => any,
371
+ push: (key: string, value: any) => any,
372
+ pop: (key: string) => any,
373
+ }
374
+