@jsonic/multisource 0.10.0 → 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.
@@ -24,6 +24,7 @@ type Resolution = PathSpec & {
24
24
  src?: string;
25
25
  val?: any;
26
26
  found: boolean;
27
+ search?: string[];
27
28
  };
28
29
  type Resolver = (spec: PathSpec, popts: MultiSourceOptions, rule: Rule, ctx: Context, jsonic: Jsonic) => Resolution;
29
30
  type Processor = (res: Resolution, popts: MultiSourceOptions, rule: Rule, ctx: Context, jsonic: Jsonic) => void;
@@ -29,7 +29,7 @@ const MultiSource = (jsonic, popts) => {
29
29
  hint: {
30
30
  // TODO: use $details for more explanation in error message.
31
31
  // In particular to show resolved absolute path.
32
- multisource_not_found: 'The source path $path was not found.',
32
+ multisource_not_found: 'The source path $path was not found.\n\nSearch paths:\n${searchstr}',
33
33
  },
34
34
  });
35
35
  // Define a directive that can load content from multiple sources.
@@ -46,7 +46,10 @@ const MultiSource = (jsonic, popts) => {
46
46
  // console.log('SRC', from, spec)
47
47
  let res = resolver(spec, popts, rule, ctx, jsonic);
48
48
  if (!res.found) {
49
- return (_a = rule.parent) === null || _a === void 0 ? void 0 : _a.o0.bad('multisource_not_found', { ...res });
49
+ return (_a = rule.parent) === null || _a === void 0 ? void 0 : _a.o0.bad('multisource_not_found', {
50
+ ...res,
51
+ searchstr: ((res === null || res === void 0 ? void 0 : res.search) || [res.full]).join('\n'),
52
+ });
50
53
  }
51
54
  res.kind = null == res.kind ? NONE : res.kind;
52
55
  let proc = processor[res.kind] || processor[NONE];
@@ -1 +1 @@
1
- {"version":3,"file":"multisource.js","sourceRoot":"","sources":["../src/multisource.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;AAGpD,iDAA+D;AAE/D,+CAAwD;AACxD,uCAAwD;AAUxD,2CAA2C;AAC3C,MAAM,IAAI,GAAG,EAAE,CAAA;AA8Ob,oBAAI;AApLN,kCAAkC;AAClC,MAAM,GAAG,GA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C,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,CAAC,GAAG,CAAC,MAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,CAAC,IAAI,CAAC,CAAA,CAAC,CAAA;IAC7D,IAAI,IAAI,GAAG,GAAG;QACZ,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,IAAI,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI;YAC5B,CAAC,CAAC,IAAI,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI;gBAC1B,CAAC,CAAC,IAAI,GAAG,GAAG,GAAG,IAAI;gBACnB,CAAC,CAAC,IAAI;YACR,CAAC,CAAC,SAAS,CAAA;IAEb,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAE9E,IAAI,GAAG,GAAe;QACpB,IAAI;QACJ,IAAI;QACJ,IAAI;QACJ,IAAI;QACJ,GAAG;QACH,KAAK,EAAE,KAAK;KACb,CAAA;IAED,OAAO,GAAG,CAAA;AACZ,CAAC;AAeC,0CAAe"}
@@ -1 +1 @@
1
- !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).JsonicMultiSource=e()}}((function(){var define,module,exports,createModuleFactory=function(e){var t;return function(n){return t||e(t={exports:{},parent:n},t.exports),t.exports}},_$multisource_1=createModuleFactory((function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TOP=t.NONE=t.resolvePathSpec=t.MultiSource=void 0;const n=_$jsonic_3({});t.NONE="";const o=Symbol("TOP");t.TOP=o;const l=(e,t)=>{const n=t.markchar,o=t.resolver,l=t.processor,{deep:r}=e.util,i=t.implictExt||[];for(let u=0;u<i.length;u++){let e=i[u];i[u]=e.startsWith(".")?e:"."+e}e.options({error:{multisource_not_found:"source not found: $path"},hint:{multisource_not_found:"The source path $path was not found."}});let s={name:"multisource",open:n,rules:{open:"val,pair"},action:function(n,i){var s;let u=n.parent.name,a=n.child.node,c=o(a,t,n,i,e);if(!c.found)return null===(s=n.parent)||void 0===s?void 0:s.o0.bad("multisource_not_found",{...c});c.kind=null==c.kind?"":c.kind,(l[c.kind]||l[""])(c,t,n,i,e),"pair"===u?i.cfg.map.merge?n.parent.parent.node=i.cfg.map.merge(n.parent.parent.node,c.val,n,i):i.cfg.map.extend?n.parent.parent.node=r(n.parent.parent.node,c.val):Object.assign(n.parent.node,c.val):n.node=c.val},custom:(e,{OPEN:t,name:n})=>{e.rule("val",e=>{e.open({s:[t],c:e=>0===e.d,p:"map",b:1,n:{[n+"_top"]:1}})}),e.rule("map",e=>{e.open({s:[t],c:e=>1===e.d&&1===e.n[n+"_top"],p:"pair",b:1})})}};e.use(_$directiveMin_4.Directive,s)};function r(e){return t=>t.val=e(t.src,t)}t.MultiSource=l;const i=r(e=>e),s=r(e=>null==e?void 0:JSON.parse(e)),u=(0,n.makeJsonicProcessor)(),a=(0,_$js_2.makeJavaScriptProcessor)();l.defaults={markchar:"@",processor:{"":i,jsonic:u,jsc:u,json:s,js:a},implictExt:["jsonic","jsc","json","js"]},t.resolvePathSpec=function(e,t,n,o){var l;let r=null===(l=t.meta)||void 0===l?void 0:l.multisource,i=o(null==r||null==r.path?e.path:r.path),s="string"==typeof n?n:null!=n.path?""+n.path:void 0,u=!(!(null==s?void 0:s.startsWith("/"))&&!(null==s?void 0:s.startsWith("\\"))),a=u?s:null!=s&&""!=s?null!=i&&""!=i?i+"/"+s:s:void 0;return{kind:null==a?"":(a.match(/\.([^.]*)$/)||["",""])[1],path:s,full:a,base:i,abs:u,found:!1}}})),_$jsonic_3=createModuleFactory((function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.makeJsonicProcessor=void 0;const n=_$multisource_1({});t.makeJsonicProcessor=function(){return function(e,t,o,l,r){var i;if(null!=e.src&&null!=e.full){let t=(null===(i=l.meta)||void 0===i?void 0:i.multisource)||{},o={...l.meta||{},multisource:{...t,path:e.full}};if(e.val=r(e.src,o),t.deps){let o=t.deps,l=t.path||n.TOP;if(null!=l){let t={tar:l,src:e.full,wen:Date.now()};o[l]=o[l]||{},o[l][e.full]=t}}}}}})),_$directiveMin_4={exports:{}};(function(e){(function(){!function(t){"object"==typeof _$directiveMin_4.exports?_$directiveMin_4.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:void 0!==e?e:"undefined"!=typeof self?self:this).JsonicDirective=t()}((function(){var e={};Object.defineProperty(e,"__esModule",{value:!0}),e.Directive=void 0;const t=e=>("string"==typeof e?e.split(/\s*,\s*/):e||[]).filter(e=>null!=e&&""!==e),n=(e,n)=>{var o,l;let r,i={open:t(null===(o=null==n?void 0:n.rules)||void 0===o?void 0:o.open),close:t(null===(l=null==n?void 0:n.rules)||void 0===l?void 0:l.close)},s=n.name,u=n.open,a=n.close,c=n.custom;if("string"==typeof n.action){let t=n.action;r=n=>n.node=e.util.prop(e.options,t)}else r=n.action;let d={},p="#OD_"+s,f="#CD_"+s,v=e.fixed(u),_=null==a?null:e.fixed(a);if(null!=v)throw new Error("Directive open token already in use: "+u);d[p]=u,null==_&&null!=a&&(d[f]=a),e.options({fixed:{token:d},error:{[s+"_close"]:null==a?null:"directive "+s+' close "'+a+'" without open "'+u+'"'},hint:{[s+"_close"]:null==a?null:`\nThe ${s} directive must start with the characters "${u}" and end\nwith the characters "${a}". The end characters "${a}" may not\nappear without the start characters "${u}" appearing first:\n"${u}...${a}".\n`}});let m=e.token.CA;v=e.fixed(u),_=null==a?null:e.fixed(a),i.open.forEach(t=>{e.rule(t,e=>(e.open({s:[v],p:s,n:{["dr_"+s]:1},g:"start"}),null!=a&&(e.open({s:[v,_],b:1,p:s,n:{["dr_"+s]:1},g:"start,end"}),e.close({s:[_],b:1,g:"end"})),e))}),null!=a&&i.close.forEach(t=>{e.rule(t,e=>{e.close([{s:[_],c:e=>1===e.n["dr_"+s],b:1,g:"end"},{s:[m,_],c:e=>1===e.n["dr_"+s],b:1,g:"end,comma"}])})}),e.rule(s,e=>e.clear().bo(e=>{e.node={}}).open([null!=a?{s:[_],b:1}:null,{p:"val",n:null==a?{dlist:1,dmap:1}:{dlist:0,dmap:0}}]).bc((function(e,t,n,o){let l=r.call(this,e,t,n,o);if(null==l?void 0:l.isToken)return l})).close(null!=a?[{s:[_]},{s:[m,_]}]:[])),c&&c(e,{OPEN:v,CLOSE:_,name:s})};return e.Directive=n,n.defaults={rules:{open:"val",close:"list,elem,map,pair"}},e}))}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{}),_$directiveMin_4=_$directiveMin_4.exports;var _$js_2={};function makeJavaScriptProcessor(e){const t=t=>{t.val=evaluate(t,e)};return t.opts=e,t}function evaluate(res,opts){let out;if(!0!==(null==opts?void 0:opts.evalOnly))out=require(res.full);else{let exports=null,module={exports:exports};eval(res.src),out=module.exports}return out}return Object.defineProperty(_$js_2,"__esModule",{value:!0}),_$js_2.makeJavaScriptProcessor=void 0,_$js_2.makeJavaScriptProcessor=makeJavaScriptProcessor,_$multisource_1(),_$multisource_1}));
1
+ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).JsonicMultiSource=e()}}((function(){var define,module,exports,createModuleFactory=function(e){var n;return function(t){return n||e(n={exports:{},parent:t},n.exports),n.exports}},_$multisource_1=createModuleFactory((function(e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.TOP=n.NONE=n.resolvePathSpec=n.MultiSource=void 0;const t=_$jsonic_3({});n.NONE="";const o=Symbol("TOP");n.TOP=o;const l=(e,n)=>{const t=n.markchar,o=n.resolver,l=n.processor,{deep:r}=e.util,i=n.implictExt||[];for(let u=0;u<i.length;u++){let e=i[u];i[u]=e.startsWith(".")?e:"."+e}e.options({error:{multisource_not_found:"source not found: $path"},hint:{multisource_not_found:"The source path $path was not found.\n\nSearch paths:\n${searchstr}"}});let s={name:"multisource",open:t,rules:{open:"val,pair"},action:function(t,i){var s;let u=t.parent.name,a=t.child.node,c=o(a,n,t,i,e);if(!c.found)return null===(s=t.parent)||void 0===s?void 0:s.o0.bad("multisource_not_found",{...c,searchstr:((null==c?void 0:c.search)||[c.full]).join("\n")});c.kind=null==c.kind?"":c.kind,(l[c.kind]||l[""])(c,n,t,i,e),"pair"===u?i.cfg.map.merge?t.parent.parent.node=i.cfg.map.merge(t.parent.parent.node,c.val,t,i):i.cfg.map.extend?t.parent.parent.node=r(t.parent.parent.node,c.val):Object.assign(t.parent.node,c.val):t.node=c.val},custom:(e,{OPEN:n,name:t})=>{e.rule("val",e=>{e.open({s:[n],c:e=>0===e.d,p:"map",b:1,n:{[t+"_top"]:1}})}),e.rule("map",e=>{e.open({s:[n],c:e=>1===e.d&&1===e.n[t+"_top"],p:"pair",b:1})})}};e.use(_$directiveMin_4.Directive,s)};function r(e){return n=>n.val=e(n.src,n)}n.MultiSource=l;const i=r(e=>e),s=r(e=>null==e?void 0:JSON.parse(e)),u=(0,t.makeJsonicProcessor)(),a=(0,_$js_2.makeJavaScriptProcessor)();l.defaults={markchar:"@",processor:{"":i,jsonic:u,jsc:u,json:s,js:a},implictExt:["jsonic","jsc","json","js"]},n.resolvePathSpec=function(e,n,t,o){var l;let r=null===(l=n.meta)||void 0===l?void 0:l.multisource,i=o(null==r||null==r.path?e.path:r.path),s="string"==typeof t?t:null!=t.path?""+t.path:void 0,u=!(!(null==s?void 0:s.startsWith("/"))&&!(null==s?void 0:s.startsWith("\\"))),a=u?s:null!=s&&""!=s?null!=i&&""!=i?i+"/"+s:s:void 0;return{kind:null==a?"":(a.match(/\.([^.]*)$/)||["",""])[1],path:s,full:a,base:i,abs:u,found:!1}}})),_$jsonic_3=createModuleFactory((function(e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.makeJsonicProcessor=void 0;const t=_$multisource_1({});n.makeJsonicProcessor=function(){return function(e,n,o,l,r){var i;if(null!=e.src&&null!=e.full){let n=(null===(i=l.meta)||void 0===i?void 0:i.multisource)||{},o={...l.meta||{},multisource:{...n,path:e.full}};if(e.val=r(e.src,o),n.deps){let o=n.deps,l=n.path||t.TOP;if(null!=l){let n={tar:l,src:e.full,wen:Date.now()};o[l]=o[l]||{},o[l][e.full]=n}}}}}})),_$directiveMin_4={exports:{}};(function(e){(function(){!function(n){"object"==typeof _$directiveMin_4.exports?_$directiveMin_4.exports=n():"function"==typeof define&&define.amd?define([],n):("undefined"!=typeof window?window:void 0!==e?e:"undefined"!=typeof self?self:this).JsonicDirective=n()}((function(){var e={};Object.defineProperty(e,"__esModule",{value:!0}),e.Directive=void 0;const n=e=>("string"==typeof e?e.split(/\s*,\s*/):e||[]).filter(e=>null!=e&&""!==e),t=(e,t)=>{var o,l;let r,i={open:n(null===(o=null==t?void 0:t.rules)||void 0===o?void 0:o.open),close:n(null===(l=null==t?void 0:t.rules)||void 0===l?void 0:l.close)},s=t.name,u=t.open,a=t.close,c=t.custom;if("string"==typeof t.action){let n=t.action;r=t=>t.node=e.util.prop(e.options,n)}else r=t.action;let d={},p="#OD_"+s,f="#CD_"+s,v=e.fixed(u),_=null==a?null:e.fixed(a);if(null!=v)throw new Error("Directive open token already in use: "+u);d[p]=u,null==_&&null!=a&&(d[f]=a),e.options({fixed:{token:d},error:{[s+"_close"]:null==a?null:"directive "+s+' close "'+a+'" without open "'+u+'"'},hint:{[s+"_close"]:null==a?null:`\nThe ${s} directive must start with the characters "${u}" and end\nwith the characters "${a}". The end characters "${a}" may not\nappear without the start characters "${u}" appearing first:\n"${u}...${a}".\n`}});let m=e.token.CA;v=e.fixed(u),_=null==a?null:e.fixed(a),i.open.forEach(n=>{e.rule(n,e=>(e.open({s:[v],p:s,n:{["dr_"+s]:1},g:"start"}),null!=a&&(e.open({s:[v,_],b:1,p:s,n:{["dr_"+s]:1},g:"start,end"}),e.close({s:[_],b:1,g:"end"})),e))}),null!=a&&i.close.forEach(n=>{e.rule(n,e=>{e.close([{s:[_],c:e=>1===e.n["dr_"+s],b:1,g:"end"},{s:[m,_],c:e=>1===e.n["dr_"+s],b:1,g:"end,comma"}])})}),e.rule(s,e=>e.clear().bo(e=>{e.node={}}).open([null!=a?{s:[_],b:1}:null,{p:"val",n:null==a?{dlist:1,dmap:1}:{dlist:0,dmap:0}}]).bc((function(e,n,t,o){let l=r.call(this,e,n,t,o);if(null==l?void 0:l.isToken)return l})).close(null!=a?[{s:[_]},{s:[m,_]}]:[])),c&&c(e,{OPEN:v,CLOSE:_,name:s})};return e.Directive=t,t.defaults={rules:{open:"val",close:"list,elem,map,pair"}},e}))}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{}),_$directiveMin_4=_$directiveMin_4.exports;var _$js_2={};function makeJavaScriptProcessor(e){const n=n=>{n.val=evaluate(n,e)};return n.opts=e,n}function evaluate(res,opts){let out;if(!0!==(null==opts?void 0:opts.evalOnly))out=require(res.full);else{let exports=null,module={exports:exports};eval(res.src),out=module.exports}return out}return Object.defineProperty(_$js_2,"__esModule",{value:!0}),_$js_2.makeJavaScriptProcessor=void 0,_$js_2.makeJavaScriptProcessor=makeJavaScriptProcessor,_$multisource_1(),_$multisource_1}));
@@ -13,11 +13,14 @@ function makeFileResolver(pathfinder) {
13
13
  let foundSpec = pathfinder ? pathfinder(spec) : spec;
14
14
  let ps = (0, multisource_1.resolvePathSpec)(popts, ctx, foundSpec, resolvefolder);
15
15
  let src = undefined;
16
+ let search = [];
16
17
  if (null != ps.full) {
17
18
  ps.full = path_1.default.resolve(ps.full);
19
+ search.push(ps.full);
18
20
  src = load(ps.full);
19
21
  if (null == src && multisource_1.NONE === ps.kind) {
20
22
  let potentials = (0, mem_1.buildPotentials)(ps, popts, (...s) => path_1.default.resolve(s.reduce((a, p) => path_1.default.join(a, p))));
23
+ search.push(...potentials);
21
24
  for (let path of potentials) {
22
25
  if (null != (src = load(path))) {
23
26
  ps.full = path;
@@ -30,7 +33,8 @@ function makeFileResolver(pathfinder) {
30
33
  let res = {
31
34
  ...ps,
32
35
  src,
33
- found: null != src
36
+ found: null != src,
37
+ search,
34
38
  };
35
39
  return res;
36
40
  };
@@ -1 +1 @@
1
- {"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/resolver/file.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AAIvB,gDAMuB;AAGvB,+BAEc;AAKd,SAAS,gBAAgB,CAAC,UAAuB;IAE/C,OAAO,SAAS,YAAY,CAC1B,IAAS,EACT,KAAyB,EACzB,KAAW,EACX,GAAY;QAEZ,IAAI,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAEpD,IAAI,EAAE,GAAG,IAAA,6BAAe,EAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,aAAa,CAAC,CAAA;QAC9D,IAAI,GAAG,GAAG,SAAS,CAAA;QAEnB,IAAI,IAAI,IAAI,EAAE,CAAC,IAAI,EAAE;YACnB,EAAE,CAAC,IAAI,GAAG,cAAI,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA;YAE/B,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA;YAEnB,IAAI,IAAI,IAAI,GAAG,IAAI,kBAAI,KAAK,EAAE,CAAC,IAAI,EAAE;gBACnC,IAAI,UAAU,GACZ,IAAA,qBAAe,EAAC,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAClC,cAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAA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,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE;wBAC9B,EAAE,CAAC,IAAI,GAAG,IAAI,CAAA;wBACd,EAAE,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,kBAAI,EAAE,kBAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;wBACvD,MAAK;qBACN;iBACF;aACF;SACF;QAED,IAAI,GAAG,GAAe;YACpB,GAAG,EAAE;YACL,GAAG;YACH,KAAK,EAAE,IAAI,IAAI,GAAG;YAClB,MAAM;SACP,CAAA;QAED,OAAO,GAAG,CAAA;IACZ,CAAC,CAAA;AACH,CAAC;AAgCC,4CAAgB;AA9BlB,SAAS,aAAa,CAAC,IAAY;IACjC,IAAI,QAAQ,KAAK,OAAO,IAAI,EAAE;QAC5B,OAAO,IAAI,CAAA;KACZ;IAED,IAAI,MAAM,GAAG,IAAI,CAAA;IACjB,IAAI,SAAS,GAAG,YAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAEjC,IAAI,SAAS,CAAC,MAAM,EAAE,EAAE;QACtB,IAAI,QAAQ,GAAG,cAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC/B,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAA;KACtB;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAGD,qEAAqE;AACrE,SAAS,IAAI,CAAC,IAAY;IACxB,IAAI;QACF,OAAO,YAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAA;KACxC;IACD,OAAO,CAAC,EAAE;QACR,6DAA6D;QAC7D,mCAAmC;KACpC;AACH,CAAC"}
@@ -4,6 +4,7 @@ exports.makeMemResolver = exports.buildPotentials = void 0;
4
4
  const multisource_1 = require("../multisource");
5
5
  function makeMemResolver(filemap) {
6
6
  return function MemResolver(spec, popts, _rule, ctx) {
7
+ // TODO: support pathfinder as file.ts
7
8
  let ps = (0, multisource_1.resolvePathSpec)(popts, ctx, spec, makeresolvefolder(filemap));
8
9
  let src = undefined;
9
10
  if (null != ps.full) {
@@ -45,26 +46,30 @@ function buildPotentials(ps, popts, pathjoin) {
45
46
  let full = ps.full;
46
47
  let potentials = [];
47
48
  let implictExt = popts.implictExt || [];
48
- // Implicit extensions.
49
- for (let ext of implictExt) {
50
- potentials.push(full + ext);
51
- }
52
- // Folder index file.
53
- for (let ext of implictExt) {
54
- potentials.push(pathjoin(full, 'index' + ext));
55
- }
56
- // Folder index file (includes folder name).
57
- if (null != ps.path) {
58
- let folder = (ps.path
59
- .replace(/[\\\/]+$/, '')
60
- .match(/[^\\\/]+$/) || [])[0];
61
- if (null != folder) {
62
- for (let ext of implictExt) {
63
- potentials.push(pathjoin(full, 'index.' + folder + ext));
49
+ let hasExt = full.match(implictExt.join('|') + '$');
50
+ // TODO: use Jsonic.util.escre
51
+ if (!hasExt) {
52
+ // Implicit extensions.
53
+ for (let ext of implictExt) {
54
+ potentials.push(full + ext);
55
+ }
56
+ // Folder index file.
57
+ for (let ext of implictExt) {
58
+ potentials.push(pathjoin(full, 'index' + ext));
59
+ }
60
+ // Folder index file (includes folder name).
61
+ if (null != ps.path) {
62
+ let folder = (ps.path
63
+ .replace(/[\\\/]+$/, '')
64
+ .match(/[^\\\/]+$/) || [])[0];
65
+ if (null != folder) {
66
+ for (let ext of implictExt) {
67
+ potentials.push(pathjoin(full, 'index.' + folder + ext));
68
+ }
64
69
  }
65
70
  }
66
71
  }
67
- // console.log(potentials)
72
+ // console.log('POT', potentials)
68
73
  return potentials;
69
74
  }
70
75
  exports.buildPotentials = buildPotentials;
@@ -1 +1 @@
1
- {"version":3,"file":"mem.js","sourceRoot":"","sources":["../../src/resolver/mem.ts"],"names":[],"mappings":";;;AAIA,gDAOuB;AAGvB,SAAS,eAAe,CAAC,OAAuC;IAE9D,OAAO,SAAS,WAAW,CACzB,IAAS,EACT,KAAyB,EACzB,KAAW,EACX,GAAY;QA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CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;YAC/B,IAAI,IAAI,IAAI,MAAM,EAAE;gBAClB,KAAK,IAAI,GAAG,IAAI,UAAU,EAAE;oBAC1B,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,GAAG,CAAC,CAAC,CAAA;iBACzD;aACF;SACF;KACF;IAED,iCAAiC;IAEjC,OAAO,UAAU,CAAA;AACnB,CAAC;AAKC,0CAAe"}
@@ -0,0 +1,3 @@
1
+ import { Resolver } from '../multisource';
2
+ declare function makePkgResolver(options: any): Resolver;
3
+ export { makePkgResolver, };
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.makePkgResolver = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const multisource_1 = require("../multisource");
10
+ const mem_1 = require("./mem");
11
+ function makePkgResolver(options) {
12
+ let useRequire = require;
13
+ let requireOptions = undefined;
14
+ if ('function' === typeof options.require) {
15
+ useRequire = options.require;
16
+ }
17
+ else if (Array.isArray(options.require)) {
18
+ requireOptions = {
19
+ paths: options.require
20
+ };
21
+ }
22
+ else if ('string' === typeof options.require) {
23
+ requireOptions = {
24
+ paths: [options.require]
25
+ };
26
+ }
27
+ return function PkgResolver(spec, popts, _rule, ctx) {
28
+ // TODO: support pathfinder as file.ts
29
+ let foundSpec = spec;
30
+ let ps = (0, multisource_1.resolvePathSpec)(popts, ctx, foundSpec, resolvefolder);
31
+ let src = undefined;
32
+ let search = [];
33
+ if (null != ps.path) {
34
+ try {
35
+ ps.full = useRequire.resolve(ps.path, requireOptions);
36
+ if (null != ps.full) {
37
+ src = load(ps.full);
38
+ }
39
+ }
40
+ catch (me) {
41
+ search.push(...((requireOptions === null || requireOptions === void 0 ? void 0 : requireOptions.paths) || (useRequire.resolve.paths(ps.path)
42
+ .map((p) => path_1.default.join(p, ps.path)))));
43
+ let potentials = (0, mem_1.buildPotentials)(ps, popts, (...s) => path_1.default.resolve(s.reduce((a, p) => path_1.default.join(a, p))));
44
+ for (let path of potentials) {
45
+ try {
46
+ ps.full = useRequire.resolve(path, requireOptions);
47
+ if (null != ps.full) {
48
+ src = load(ps.full);
49
+ }
50
+ }
51
+ catch (me) {
52
+ search.push(...((requireOptions === null || requireOptions === void 0 ? void 0 : requireOptions.paths) || (useRequire.resolve.paths(path)
53
+ .map((p) => path_1.default.join(p, path)))));
54
+ }
55
+ }
56
+ }
57
+ }
58
+ let res = {
59
+ ...ps,
60
+ src,
61
+ found: null != src,
62
+ search,
63
+ };
64
+ return res;
65
+ };
66
+ }
67
+ exports.makePkgResolver = makePkgResolver;
68
+ function resolvefolder(path) {
69
+ if ('string' !== typeof path) {
70
+ return path;
71
+ }
72
+ let folder = path;
73
+ let pathstats = fs_1.default.statSync(path);
74
+ if (pathstats.isFile()) {
75
+ let pathdesc = path_1.default.parse(path);
76
+ folder = pathdesc.dir;
77
+ }
78
+ return folder;
79
+ }
80
+ // TODO: in multisource.ts, generate an error token if cannot resolve
81
+ function load(path) {
82
+ try {
83
+ return fs_1.default.readFileSync(path).toString();
84
+ }
85
+ catch (e) {
86
+ // NOTE: don't need this, as in all cases, we consider failed
87
+ // reads to indicate non-existence.
88
+ }
89
+ }
90
+ //# sourceMappingURL=pkg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pkg.js","sourceRoot":"","sources":["../../src/resolver/pkg.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AAIvB,gDAMuB;AAGvB,+BAEc;AAGd,SAAS,eAAe,CAAC,OAAY;IACnC,IAAI,UAAU,GAAQ,OAAO,CAAA;IAC7B,IAAI,cAAc,GAAQ,SAAS,CAAA;IAEnC,IAAI,UAAU,KA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,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAEjC,IAAI,SAAS,CAAC,MAAM,EAAE,EAAE;QACtB,IAAI,QAAQ,GAAG,cAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC/B,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAA;KACtB;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAGD,qEAAqE;AACrE,SAAS,IAAI,CAAC,IAAY;IACxB,IAAI;QACF,OAAO,YAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAA;KACxC;IACD,OAAO,CAAC,EAAE;QACR,6DAA6D;QAC7D,mCAAmC;KACpC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsonic/multisource",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "",
5
5
  "main": "dist/multisource.js",
6
6
  "type": "commonjs",
@@ -41,19 +41,19 @@
41
41
  "dist"
42
42
  ],
43
43
  "devDependencies": {
44
- "@types/jest": "^29.4.0",
44
+ "@types/jest": "^29.5.0",
45
45
  "browserify": "^17.0.0",
46
- "esbuild": "^0.17.8",
46
+ "es-jest": "^2.1.0",
47
+ "esbuild": "^0.17.12",
47
48
  "esbuild-jest": "^0.5.0",
48
- "jest": "^29.4.3",
49
- "prettier": "^2.8.4",
49
+ "jest": "^29.5.0",
50
+ "prettier": "^2.8.5",
50
51
  "tinyify": "^4.0.0",
51
- "es-jest": "^2.1.0",
52
- "typescript": "^4.9.5"
52
+ "typescript": "^5.0.2",
53
+ "jsonic-multisource-pkg-test": "^0.0.1"
53
54
  },
54
55
  "peerDependencies": {
55
- "@jsonic/jsonic-next": ">=2.9.0",
56
- "@jsonic/directive": ">=0.10.0"
57
- },
58
- "dependencies": {}
56
+ "@jsonic/directive": ">=0.11.0",
57
+ "@jsonic/jsonic-next": ">=2.10.0"
58
+ }
59
59
  }
@@ -40,6 +40,7 @@ type Resolution = PathSpec & {
40
40
  src?: string // Undefined if no resolution
41
41
  val?: any // Undefined if no resolution
42
42
  found: boolean // True if source file was found
43
+ search?: string[] // List of searched paths.
43
44
  }
44
45
 
45
46
  // Resolve the source.
@@ -97,7 +98,8 @@ const MultiSource: Plugin = (jsonic: Jsonic, popts: MultiSourceOptions) => {
97
98
  hint: {
98
99
  // TODO: use $details for more explanation in error message.
99
100
  // In particular to show resolved absolute path.
100
- multisource_not_found: 'The source path $path was not found.',
101
+ multisource_not_found:
102
+ 'The source path $path was not found.\n\nSearch paths:\n${searchstr}',
101
103
  },
102
104
  })
103
105
 
@@ -115,7 +117,10 @@ const MultiSource: Plugin = (jsonic: Jsonic, popts: MultiSourceOptions) => {
115
117
 
116
118
  let res = resolver(spec, popts, rule, ctx, jsonic)
117
119
  if (!res.found) {
118
- return rule.parent?.o0.bad('multisource_not_found', { ...res })
120
+ return rule.parent?.o0.bad('multisource_not_found', {
121
+ ...res,
122
+ searchstr: (res?.search || [res.full]).join('\n'),
123
+ })
119
124
  }
120
125
 
121
126
  res.kind = null == res.kind ? NONE : res.kind
@@ -32,15 +32,20 @@ function makeFileResolver(pathfinder?: PathFinder): Resolver {
32
32
  let ps = resolvePathSpec(popts, ctx, foundSpec, resolvefolder)
33
33
  let src = undefined
34
34
 
35
+ let search: string[] = []
36
+
35
37
  if (null != ps.full) {
36
38
  ps.full = Path.resolve(ps.full)
37
39
 
40
+ search.push(ps.full)
38
41
  src = load(ps.full)
39
42
 
43
+
40
44
  if (null == src && NONE === ps.kind) {
41
45
  let potentials =
42
46
  buildPotentials(ps, popts, (...s) =>
43
47
  Path.resolve(s.reduce((a, p) => Path.join(a, p))))
48
+ search.push(...potentials)
44
49
 
45
50
  for (let path of potentials) {
46
51
  if (null != (src = load(path))) {
@@ -55,7 +60,8 @@ function makeFileResolver(pathfinder?: PathFinder): Resolver {
55
60
  let res: Resolution = {
56
61
  ...ps,
57
62
  src,
58
- found: null != src
63
+ found: null != src,
64
+ search,
59
65
  }
60
66
 
61
67
  return res
@@ -20,6 +20,8 @@ function makeMemResolver(filemap: { [fullpath: string]: string }): Resolver {
20
20
  _rule: Rule,
21
21
  ctx: Context,
22
22
  ): Resolution {
23
+ // TODO: support pathfinder as file.ts
24
+
23
25
  let ps = resolvePathSpec(popts, ctx, spec, makeresolvefolder(filemap))
24
26
  let src = undefined
25
27
 
@@ -74,30 +76,34 @@ function buildPotentials(
74
76
  let full = (ps.full as string)
75
77
  let potentials: string[] = []
76
78
  let implictExt: string[] = popts.implictExt || []
79
+ let hasExt = full.match(implictExt.join('|') + '$')
77
80
 
78
- // Implicit extensions.
79
- for (let ext of implictExt) {
80
- potentials.push(full + ext)
81
- }
81
+ // TODO: use Jsonic.util.escre
82
+ if (!hasExt) {
83
+ // Implicit extensions.
84
+ for (let ext of implictExt) {
85
+ potentials.push(full + ext)
86
+ }
82
87
 
83
- // Folder index file.
84
- for (let ext of implictExt) {
85
- potentials.push(pathjoin(full, 'index' + ext))
86
- }
88
+ // Folder index file.
89
+ for (let ext of implictExt) {
90
+ potentials.push(pathjoin(full, 'index' + ext))
91
+ }
87
92
 
88
- // Folder index file (includes folder name).
89
- if (null != ps.path) {
90
- let folder = (ps.path
91
- .replace(/[\\\/]+$/, '')
92
- .match(/[^\\\/]+$/) || [])[0]
93
- if (null != folder) {
94
- for (let ext of implictExt) {
95
- potentials.push(pathjoin(full, 'index.' + folder + ext))
93
+ // Folder index file (includes folder name).
94
+ if (null != ps.path) {
95
+ let folder = (ps.path
96
+ .replace(/[\\\/]+$/, '')
97
+ .match(/[^\\\/]+$/) || [])[0]
98
+ if (null != folder) {
99
+ for (let ext of implictExt) {
100
+ potentials.push(pathjoin(full, 'index.' + folder + ext))
101
+ }
96
102
  }
97
103
  }
98
104
  }
99
105
 
100
- // console.log(potentials)
106
+ // console.log('POT', potentials)
101
107
 
102
108
  return potentials
103
109
  }
@@ -0,0 +1,125 @@
1
+ import Fs from 'fs'
2
+ import Path from 'path'
3
+
4
+ import { Rule, Context } from '@jsonic/jsonic-next'
5
+
6
+ import {
7
+ MultiSourceOptions,
8
+ Resolver,
9
+ Resolution,
10
+ resolvePathSpec,
11
+ // NONE,
12
+ } from '../multisource'
13
+
14
+
15
+ import {
16
+ buildPotentials
17
+ } from './mem'
18
+
19
+
20
+ function makePkgResolver(options: any): Resolver {
21
+ let useRequire: any = require
22
+ let requireOptions: any = undefined
23
+
24
+ if ('function' === typeof options.require) {
25
+ useRequire = options.require
26
+ }
27
+ else if (Array.isArray(options.require)) {
28
+ requireOptions = {
29
+ paths: options.require
30
+ }
31
+ }
32
+ else if ('string' === typeof options.require) {
33
+ requireOptions = {
34
+ paths: [options.require]
35
+ }
36
+ }
37
+
38
+ return function PkgResolver(
39
+ spec: any,
40
+ popts: MultiSourceOptions,
41
+ _rule: Rule,
42
+ ctx: Context,
43
+ ): Resolution {
44
+ // TODO: support pathfinder as file.ts
45
+
46
+ let foundSpec = spec
47
+
48
+ let ps = resolvePathSpec(popts, ctx, foundSpec, resolvefolder)
49
+ let src = undefined
50
+ let search: string[] = []
51
+
52
+ if (null != ps.path) {
53
+ try {
54
+ ps.full = useRequire.resolve(ps.path, requireOptions)
55
+ if (null != ps.full) {
56
+ src = load(ps.full)
57
+ }
58
+ }
59
+ catch (me: any) {
60
+ search.push(...(requireOptions?.paths || (useRequire.resolve.paths(ps.path)
61
+ .map((p: string) => Path.join(p, (ps.path as string))))))
62
+
63
+ let potentials =
64
+ buildPotentials(ps, popts, (...s) =>
65
+ Path.resolve(s.reduce((a, p) => Path.join(a, p))))
66
+
67
+ for (let path of potentials) {
68
+ try {
69
+ ps.full = useRequire.resolve(path, requireOptions)
70
+ if (null != ps.full) {
71
+ src = load(ps.full)
72
+ }
73
+ }
74
+ catch (me: any) {
75
+ search.push(...(requireOptions?.paths || (useRequire.resolve.paths(path)
76
+ .map((p: string) => Path.join(p, (path as string))))))
77
+ }
78
+ }
79
+ }
80
+ }
81
+
82
+ let res: Resolution = {
83
+ ...ps,
84
+ src,
85
+ found: null != src,
86
+ search,
87
+ }
88
+
89
+ return res
90
+ }
91
+ }
92
+
93
+
94
+ function resolvefolder(path: string) {
95
+ if ('string' !== typeof path) {
96
+ return path
97
+ }
98
+
99
+ let folder = path
100
+ let pathstats = Fs.statSync(path)
101
+
102
+ if (pathstats.isFile()) {
103
+ let pathdesc = Path.parse(path)
104
+ folder = pathdesc.dir
105
+ }
106
+
107
+ return folder
108
+ }
109
+
110
+
111
+ // TODO: in multisource.ts, generate an error token if cannot resolve
112
+ function load(path: string) {
113
+ try {
114
+ return Fs.readFileSync(path).toString()
115
+ }
116
+ catch (e) {
117
+ // NOTE: don't need this, as in all cases, we consider failed
118
+ // reads to indicate non-existence.
119
+ }
120
+ }
121
+
122
+
123
+ export {
124
+ makePkgResolver,
125
+ }