@jsonic/multisource 0.3.0 → 0.6.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/dist/multisource.d.ts +1 -1
- package/dist/multisource.js +2 -1
- package/dist/multisource.js.map +1 -1
- package/dist/multisource.min.js +1 -1
- package/package.json +9 -9
- package/src/multisource.ts +4 -2
- package/src/processor/jsonic.ts +1 -1
- package/src/resolver/file.ts +1 -1
- package/src/resolver/mem.ts +1 -1
package/dist/multisource.d.ts
CHANGED
package/dist/multisource.js
CHANGED
|
@@ -35,7 +35,7 @@ const MultiSource = (jsonic, popts) => {
|
|
|
35
35
|
let dopts = {
|
|
36
36
|
name: 'multisource',
|
|
37
37
|
open: markchar,
|
|
38
|
-
action: (rule, ctx)
|
|
38
|
+
action: function multisourceStateAction(rule, ctx) {
|
|
39
39
|
var _a;
|
|
40
40
|
let spec = rule.child.node;
|
|
41
41
|
let res = resolver(spec, popts, rule, ctx, jsonic);
|
|
@@ -46,6 +46,7 @@ const MultiSource = (jsonic, popts) => {
|
|
|
46
46
|
let proc = processor[res.kind] || processor[NONE];
|
|
47
47
|
proc(res, popts, rule, ctx, jsonic);
|
|
48
48
|
rule.node = res.val;
|
|
49
|
+
return undefined;
|
|
49
50
|
},
|
|
50
51
|
};
|
|
51
52
|
jsonic.use(directive_1.Directive, dopts);
|
package/dist/multisource.js.map
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"multisource.js","sourceRoot":"","sources":["../src/multisource.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;AAGpD,iDAA+D;AAE/D,+CAAwD;AACxD,uCAAwD;AAUxD,2CAA2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AAG,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"}
|
package/dist/multisource.min.js
CHANGED
|
@@ -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(o){return t||e(t={exports:{},parent:o},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 o=_$jsonic_3({});t.NONE="";const n=Symbol("TOP");t.TOP=n;const l=(e,t)=>{const o=t.markchar,n=t.resolver,l=t.processor,i=t.implictExt||[];for(let s=0;s<i.length;s++){let e=i[s];i[s]=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 r={name:"multisource",open:o,action:(o,i)
|
|
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(o){return t||e(t={exports:{},parent:o},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 o=_$jsonic_3({});t.NONE="";const n=Symbol("TOP");t.TOP=n;const l=(e,t)=>{const o=t.markchar,n=t.resolver,l=t.processor,i=t.implictExt||[];for(let s=0;s<i.length;s++){let e=i[s];i[s]=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 r={name:"multisource",open:o,action:function(o,i){var r;let s=o.child.node,u=n(s,t,o,i,e);if(!u.found)return null===(r=o.parent)||void 0===r?void 0:r.o0.bad("multisource_not_found",{...u});u.kind=null==u.kind?"":u.kind,(l[u.kind]||l[""])(u,t,o,i,e),o.node=u.val}};e.use(_$directiveMin_4.Directive,r)};function i(e){return t=>t.val=e(t.src,t)}t.MultiSource=l;const r=i(e=>e),s=i(e=>null==e?void 0:JSON.parse(e)),u=(0,o.makeJsonicProcessor)(),c=(0,_$js_2.makeJavaScriptProcessor)();l.defaults={markchar:"@",processor:{"":r,jsonic:u,jsc:u,json:s,js:c},implictExt:["jsonic","jsc","json","js"]},t.resolvePathSpec=function(e,t,o,n){var l;let i=null===(l=t.meta)||void 0===l?void 0:l.multisource,r=n(null==i||null==i.path?e.path:i.path),s="string"==typeof o?o:null!=o.path?""+o.path:void 0,u=!(!(null==s?void 0:s.startsWith("/"))&&!(null==s?void 0:s.startsWith("\\"))),c=u?s:null!=s&&""!=s?null!=r&&""!=r?r+"/"+s:s:void 0;return{kind:null==c?"":(c.match(/\.([^.]*)$/)||["",""])[1],path:s,full:c,base:r,abs:u,found:!1}}})),_$jsonic_3=createModuleFactory((function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.makeJsonicProcessor=void 0;const o=_$multisource_1({});t.makeJsonicProcessor=function(){return function(e,t,n,l,i){var r;if(null!=e.src&&null!=e.full){let t=(null===(r=l.meta)||void 0===r?void 0:r.multisource)||{},n={...l.meta||{},multisource:{...t,path:e.full}};if(e.val=i(e.src,n),t.deps){let n=t.deps,l=t.path||o.TOP;if(null!=l){let t={tar:l,src:e.full,wen:Date.now()};n[l]=n[l]||{},n[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,t)=>{let o,n=("string"==typeof t.rules?t.rules.split(/\s*,\s*/):t.rules||[]).filter(e=>""!==e),l=t.name,i=t.open,r=t.close;if("string"==typeof t.action){let n=t.action;o=t=>t.node=e.util.prop(e.options,n)}else o=t.action;let s={},u="#D_open_"+l,c="#D_close_"+l,a=e.fixed(i),d=null==r?null:e.fixed(r);if(null!=a)throw new Error("Directive open token already in use: "+i);s[u]=i,null==d&&null!=r&&(s[c]=r),e.options({fixed:{token:s},error:{[l+"_close"]:null==r?null:"directive "+l+' close "'+r+'" without open "'+i+'"'},hint:{[l+"_close"]:null==r?null:`\nThe ${l} directive must start with the characters "${i}" and end\nwith the characters "${r}". The end characters "${r}" may not\nappear without the start characters "${i}" appearing first:\n"${i}...${r}".\n`}});let f=e.token.CA;a=e.fixed(i),d=null==r?null:e.fixed(r),n.forEach(t=>{e.rule(t,e=>(e.open({s:[a],p:l,n:{dr:1}}),null!=r&&(e.open([{s:[d],c:{n:{dr:0}},e:(e,t)=>t.t0.bad(l+"_close")},{s:[d],b:1}]),e.close({s:[d],b:1})),e))}),e.rule(l,e=>e.clear().bo(e=>{e.node={}}).open([{p:"val",n:null==r?{}:{pk:-1,il:0}}]).bc((function(e,t){let n=o.call(this,e,t);if(null==n?void 0:n.isToken)return n})).close(null!=r?[{s:[d]},{s:[f,d]}]:[]))};return e.Directive=t,t.defaults={rules:"val,pair,elem"},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=void 0;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}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsonic/multisource",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/multisource.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -41,18 +41,18 @@
|
|
|
41
41
|
"dist"
|
|
42
42
|
],
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@types/jest": "^27.
|
|
44
|
+
"@types/jest": "^27.5.1",
|
|
45
45
|
"browserify": "^17.0.0",
|
|
46
|
-
"esbuild": "^0.14.
|
|
46
|
+
"esbuild": "^0.14.42",
|
|
47
47
|
"esbuild-jest": "^0.5.0",
|
|
48
|
-
"jest": "^
|
|
49
|
-
"jsonic": "
|
|
50
|
-
"prettier": "^2.6.
|
|
48
|
+
"jest": "^28.1.0",
|
|
49
|
+
"@jsonic/jsonic-next": "2.0.2",
|
|
50
|
+
"prettier": "^2.6.2",
|
|
51
51
|
"tinyify": "^3.0.0",
|
|
52
|
-
"ts-jest": "^
|
|
53
|
-
"typescript": "^4.
|
|
52
|
+
"ts-jest": "^28.0.3",
|
|
53
|
+
"typescript": "^4.7.2"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@jsonic/directive": "^0.
|
|
56
|
+
"@jsonic/directive": "^0.7.0"
|
|
57
57
|
}
|
|
58
58
|
}
|
package/src/multisource.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* Copyright (c) 2021 Richard Rodger, MIT License */
|
|
2
2
|
|
|
3
|
-
import { Jsonic, Context, Rule, Plugin } from 'jsonic'
|
|
3
|
+
import { Jsonic, Context, Rule, Plugin } from '@jsonic/jsonic-next'
|
|
4
4
|
import { Directive, DirectiveOptions } from '@jsonic/directive'
|
|
5
5
|
|
|
6
6
|
import { makeJsonicProcessor } from './processor/jsonic'
|
|
@@ -103,7 +103,7 @@ const MultiSource: Plugin = (jsonic: Jsonic, popts: MultiSourceOptions) => {
|
|
|
103
103
|
let dopts: DirectiveOptions = {
|
|
104
104
|
name: 'multisource',
|
|
105
105
|
open: markchar,
|
|
106
|
-
action: (rule: Rule, ctx: Context)
|
|
106
|
+
action: function multisourceStateAction(rule: Rule, ctx: Context) {
|
|
107
107
|
let spec = rule.child.node
|
|
108
108
|
|
|
109
109
|
let res = resolver(spec, popts, rule, ctx, jsonic)
|
|
@@ -117,6 +117,8 @@ const MultiSource: Plugin = (jsonic: Jsonic, popts: MultiSourceOptions) => {
|
|
|
117
117
|
proc(res, popts, rule, ctx, jsonic)
|
|
118
118
|
|
|
119
119
|
rule.node = res.val
|
|
120
|
+
|
|
121
|
+
return undefined
|
|
120
122
|
},
|
|
121
123
|
}
|
|
122
124
|
jsonic.use(Directive, dopts)
|
package/src/processor/jsonic.ts
CHANGED
package/src/resolver/file.ts
CHANGED