Add archify-vscode-ext skill: Archify diagrams and models for the Archify Diagram Viewer extension
Model tasks (validate, list, scaffold, resolve), diagram tasks (validate, render), the bundled Archify 3.0.1 runtime and yaml parser under scripts/vendor, references for authoring, formats and folders, and the online-shop example model.
This commit is contained in:
commit
b6b5e57922
226 files changed
+67520
No files matched your search
+19
@@ -0,0 +1,19 @@
|
||||
import { Scalar } from '../../nodes/Scalar.js';
|
||||
|
||||
const boolTag = {
|
||||
identify: value => typeof value === 'boolean',
|
||||
default: true,
|
||||
tag: 'tag:yaml.org,2002:bool',
|
||||
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
||||
resolve: str => new Scalar(str[0] === 't' || str[0] === 'T'),
|
||||
stringify({ source, value }, ctx) {
|
||||
if (source && boolTag.test.test(source)) {
|
||||
const sv = source[0] === 't' || source[0] === 'T';
|
||||
if (value === sv)
|
||||
return source;
|
||||
}
|
||||
return value ? ctx.options.trueStr : ctx.options.falseStr;
|
||||
}
|
||||
};
|
||||
|
||||
export { boolTag };
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
import { Scalar } from '../../nodes/Scalar.js';
|
||||
import { stringifyNumber } from '../../stringify/stringifyNumber.js';
|
||||
|
||||
const floatNaN = {
|
||||
identify: value => typeof value === 'number',
|
||||
default: true,
|
||||
tag: 'tag:yaml.org,2002:float',
|
||||
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
||||
resolve: str => str.slice(-3).toLowerCase() === 'nan'
|
||||
? NaN
|
||||
: str[0] === '-'
|
||||
? Number.NEGATIVE_INFINITY
|
||||
: Number.POSITIVE_INFINITY,
|
||||
stringify: stringifyNumber
|
||||
};
|
||||
const floatExp = {
|
||||
identify: value => typeof value === 'number',
|
||||
default: true,
|
||||
tag: 'tag:yaml.org,2002:float',
|
||||
format: 'EXP',
|
||||
test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
|
||||
resolve: str => parseFloat(str),
|
||||
stringify(node) {
|
||||
const num = Number(node.value);
|
||||
return isFinite(num) ? num.toExponential() : stringifyNumber(node);
|
||||
}
|
||||
};
|
||||
const float = {
|
||||
identify: value => typeof value === 'number',
|
||||
default: true,
|
||||
tag: 'tag:yaml.org,2002:float',
|
||||
test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
|
||||
resolve(str) {
|
||||
const node = new Scalar(parseFloat(str));
|
||||
const dot = str.indexOf('.');
|
||||
if (dot !== -1 && str[str.length - 1] === '0')
|
||||
node.minFractionDigits = str.length - dot - 1;
|
||||
return node;
|
||||
},
|
||||
stringify: stringifyNumber
|
||||
};
|
||||
|
||||
export { float, floatExp, floatNaN };
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
import { stringifyNumber } from '../../stringify/stringifyNumber.js';
|
||||
|
||||
const intIdentify = (value) => typeof value === 'bigint' || Number.isInteger(value);
|
||||
const intResolve = (str, offset, radix, { intAsBigInt }) => (intAsBigInt ? BigInt(str) : parseInt(str.substring(offset), radix));
|
||||
function intStringify(node, radix, prefix) {
|
||||
const { value } = node;
|
||||
if (intIdentify(value) && value >= 0)
|
||||
return prefix + value.toString(radix);
|
||||
return stringifyNumber(node);
|
||||
}
|
||||
const intOct = {
|
||||
identify: value => intIdentify(value) && value >= 0,
|
||||
default: true,
|
||||
tag: 'tag:yaml.org,2002:int',
|
||||
format: 'OCT',
|
||||
test: /^0o[0-7]+$/,
|
||||
resolve: (str, _onError, opt) => intResolve(str, 2, 8, opt),
|
||||
stringify: node => intStringify(node, 8, '0o')
|
||||
};
|
||||
const int = {
|
||||
identify: intIdentify,
|
||||
default: true,
|
||||
tag: 'tag:yaml.org,2002:int',
|
||||
test: /^[-+]?[0-9]+$/,
|
||||
resolve: (str, _onError, opt) => intResolve(str, 0, 10, opt),
|
||||
stringify: stringifyNumber
|
||||
};
|
||||
const intHex = {
|
||||
identify: value => intIdentify(value) && value >= 0,
|
||||
default: true,
|
||||
tag: 'tag:yaml.org,2002:int',
|
||||
format: 'HEX',
|
||||
test: /^0x[0-9a-fA-F]+$/,
|
||||
resolve: (str, _onError, opt) => intResolve(str, 2, 16, opt),
|
||||
stringify: node => intStringify(node, 16, '0x')
|
||||
};
|
||||
|
||||
export { int, intHex, intOct };
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import { map } from '../common/map.js';
|
||||
import { nullTag } from '../common/null.js';
|
||||
import { seq } from '../common/seq.js';
|
||||
import { string } from '../common/string.js';
|
||||
import { boolTag } from './bool.js';
|
||||
import { floatNaN, floatExp, float } from './float.js';
|
||||
import { intOct, int, intHex } from './int.js';
|
||||
|
||||
const schema = [
|
||||
map,
|
||||
seq,
|
||||
string,
|
||||
nullTag,
|
||||
boolTag,
|
||||
intOct,
|
||||
int,
|
||||
intHex,
|
||||
floatNaN,
|
||||
floatExp,
|
||||
float
|
||||
];
|
||||
|
||||
export { schema };
|
||||
Reference in new issue
Block a user