@makano/rew 1.2.83 → 1.2.84

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.
@@ -1,3 +1,4 @@
1
1
  Function.prototype.wait = function(...args) {
2
2
  return wait(this, ...args);
3
- };
3
+ };
4
+ Function.prototype.globe = () => global
@@ -64,24 +64,26 @@ module.exports.Usage = class Usage {
64
64
 
65
65
  class Namespace extends module.exports.Usage {
66
66
  namespace = {};
67
- constructor(ns, cb){
67
+ constructor(ns, cb, parent){
68
68
  super('namespace');
69
69
  if(ns instanceof Namespace.Group){
70
70
  if(ns.onUse) this.onUse = ns.onUse;
71
+ if(ns.parent) parent = ns.parent;
71
72
  cb = ns.g[1]
72
73
  ns = ns.g[0]
73
74
  }
74
75
  this.save = false;
75
76
  this.trigger = cb;
76
77
  this.namespace = ns;
78
+ this.parent = parent;
77
79
  }
78
80
 
79
81
  static Group = class NamespaceGroup extends module.exports.Usage.Group {}
80
82
  }
81
83
  module.exports.Namespace = Namespace;
82
84
 
83
- module.exports.namespace = (namespace, cb) => {
84
- return new Namespace(namespace, cb);
85
+ module.exports.namespace = (namespace, cb, parent) => {
86
+ return new Namespace(namespace, cb, parent);
85
87
  }
86
88
 
87
89
  module.exports.namespace.group = (group, props) => new Namespace.Group(group, props);
@@ -326,16 +326,17 @@ function compileRewStuff(content, options) {
326
326
  nextToken.value &&
327
327
  nextToken.value !== 'undefined' && !options.keepImports
328
328
  ) {
329
- let next = {...nextToken};
329
+ let next = {...nextToken}, isClass = false;
330
330
  if(next.value == 'default'){
331
331
  i += 2;
332
332
  }
333
333
  if(next.value == 'class'){
334
334
  next.value = gnextToken(i, n + 1, tokens)?.token.value || "default";
335
+ isClass = true;
335
336
  }
336
337
  hooks.push({
337
338
  index: i + 1,
338
- value: `"${next.value}", `,
339
+ value: `"${next.value}", ${isClass ? `${next.value} = ` : ''}`,
339
340
  });
340
341
  }
341
342
 
@@ -123,9 +123,10 @@ module.exports.prepareContext = function (
123
123
  }
124
124
  } else if(name instanceof Namespace) {
125
125
  const trigger = name.trigger;
126
- const childContext = {...context, ...name.namespace, trigger};
126
+ const parentContext = name.parent || context;
127
+ const childContext = {...parentContext, ...name.namespace, trigger};
127
128
  childContext.currentNamespace = name.namespace;
128
- childContext.parentNamespace = context;
129
+ childContext.parentNamespace = parentContext;
129
130
  const code = `(${trigger.toString()})()`;
130
131
  if(name.onUse) name.onUse();
131
132
  return runtime.exec(code, childContext, code, context.module.filepath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.2.83",
3
+ "version": "1.2.84",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {