solve-engine 1.0.0-beta.2 → 1.0.0-beta.4
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/{Lexer-D9l4Yrk2.d.ts → Lexer-Cfm79Dak.d.cts} +18 -2
- package/dist/{Lexer-BJdhlnej.d.cts → Lexer-W9MBOP0V.d.ts} +18 -2
- package/dist/{PackageRegistry-DaH4aIKP.d.ts → PackageRegistry-CjDt-Jy_.d.ts} +60 -4
- package/dist/{PackageRegistry-D-Tv_7ca.d.cts → PackageRegistry-pHtKythi.d.cts} +60 -4
- package/dist/{Parselet-CK8cQu2a.d.cts → Parselet-Cu0bLSis.d.cts} +1 -1
- package/dist/{Parselet-ConOIdRO.d.ts → Parselet-DEdF9I7n.d.ts} +1 -1
- package/dist/{Token-0jpvUdPY.d.cts → Token-BzG5G4ja.d.cts} +44 -0
- package/dist/{Token-0jpvUdPY.d.ts → Token-BzG5G4ja.d.ts} +44 -0
- package/dist/TokenNormalizer-DGVa24Q-.d.cts +377 -0
- package/dist/TokenNormalizer-t_GotBxr.d.ts +377 -0
- package/dist/{chunk-HWSZJQCI.js → chunk-2CS6OMZK.js} +37 -15
- package/dist/chunk-2CS6OMZK.js.map +1 -0
- package/dist/{chunk-XJCMXB2E.cjs → chunk-2MV4HBKC.cjs} +187 -61
- package/dist/chunk-2MV4HBKC.cjs.map +1 -0
- package/dist/{chunk-J73SJHR3.cjs → chunk-2NPS5DQ3.cjs} +558 -341
- package/dist/chunk-2NPS5DQ3.cjs.map +1 -0
- package/dist/{chunk-QWY3VEZN.js → chunk-3MNKQZ77.js} +65 -12
- package/dist/chunk-3MNKQZ77.js.map +1 -0
- package/dist/{chunk-RZCWSXTA.cjs → chunk-43G3JT2E.cjs} +1491 -218
- package/dist/chunk-43G3JT2E.cjs.map +1 -0
- package/dist/{chunk-WQTTOGXC.cjs → chunk-4AVD7NZW.cjs} +4 -4
- package/dist/{chunk-WQTTOGXC.cjs.map → chunk-4AVD7NZW.cjs.map} +1 -1
- package/dist/{chunk-HTXVVJRA.cjs → chunk-4CVLFLOB.cjs} +112 -2
- package/dist/chunk-4CVLFLOB.cjs.map +1 -0
- package/dist/{chunk-5YEMOYSE.js → chunk-6GCKCWLB.js} +9 -3
- package/dist/chunk-6GCKCWLB.js.map +1 -0
- package/dist/{chunk-EBSPLUW4.cjs → chunk-AHCLWAM5.cjs} +28 -10
- package/dist/chunk-AHCLWAM5.cjs.map +1 -0
- package/dist/{chunk-KVILKGMS.js → chunk-AJA6LUI7.js} +36 -2
- package/dist/chunk-AJA6LUI7.js.map +1 -0
- package/dist/{chunk-EHAHVROS.cjs → chunk-CLVQBF5C.cjs} +5 -5
- package/dist/{chunk-EHAHVROS.cjs.map → chunk-CLVQBF5C.cjs.map} +1 -1
- package/dist/{chunk-34RRD7PC.js → chunk-CYFK5SY2.js} +111 -3
- package/dist/chunk-CYFK5SY2.js.map +1 -0
- package/dist/{chunk-M5LX5AOO.js → chunk-DDQVZGLO.js} +25 -12
- package/dist/chunk-DDQVZGLO.js.map +1 -0
- package/dist/{chunk-LR7YASZF.cjs → chunk-EAAHVJ4P.cjs} +3 -3
- package/dist/chunk-EAAHVJ4P.cjs.map +1 -0
- package/dist/{chunk-3PPFLFH4.js → chunk-FIFQPKBA.js} +1417 -144
- package/dist/chunk-FIFQPKBA.js.map +1 -0
- package/dist/{chunk-RIN643A3.js → chunk-GPPLSM2Z.js} +61 -2
- package/dist/chunk-GPPLSM2Z.js.map +1 -0
- package/dist/{chunk-4QADQTWS.js → chunk-KHJUSHFU.js} +231 -14
- package/dist/chunk-KHJUSHFU.js.map +1 -0
- package/dist/{chunk-NMD5VRN4.cjs → chunk-M4F66R4O.cjs} +74 -73
- package/dist/chunk-M4F66R4O.cjs.map +1 -0
- package/dist/{chunk-6NTVRDQV.cjs → chunk-M4Q47KHF.cjs} +126 -73
- package/dist/chunk-M4Q47KHF.cjs.map +1 -0
- package/dist/{chunk-LIPPNDBE.js → chunk-M5E34VG5.js} +3 -3
- package/dist/{chunk-LIPPNDBE.js.map → chunk-M5E34VG5.js.map} +1 -1
- package/dist/{chunk-53B6KDDJ.cjs → chunk-MBNQVDVC.cjs} +38 -3
- package/dist/{chunk-53B6KDDJ.cjs.map → chunk-MBNQVDVC.cjs.map} +1 -1
- package/dist/{chunk-SDGRK7EP.js → chunk-MEOHSQEH.js} +6 -5
- package/dist/chunk-MEOHSQEH.js.map +1 -0
- package/dist/{chunk-NMCRQP3Z.cjs → chunk-MTX2KVU7.cjs} +71 -70
- package/dist/chunk-MTX2KVU7.cjs.map +1 -0
- package/dist/{chunk-QNJ4ACRT.cjs → chunk-NJTXJ5AG.cjs} +37 -15
- package/dist/chunk-NJTXJ5AG.cjs.map +1 -0
- package/dist/{chunk-C4XZV6E7.cjs → chunk-NZFKROS7.cjs} +26 -20
- package/dist/chunk-NZFKROS7.cjs.map +1 -0
- package/dist/{chunk-64W6GLLZ.js → chunk-OFXOTECC.js} +24 -6
- package/dist/chunk-OFXOTECC.js.map +1 -0
- package/dist/{chunk-3YNVWKR2.cjs → chunk-OUHT5Z36.cjs} +28 -5
- package/dist/chunk-OUHT5Z36.cjs.map +1 -0
- package/dist/{chunk-EIGTWK5N.js → chunk-OWRHDUJD.js} +3 -3
- package/dist/chunk-OWRHDUJD.js.map +1 -0
- package/dist/{chunk-4MG4XKO2.js → chunk-PCPX42KL.js} +38 -3
- package/dist/{chunk-4MG4XKO2.js.map → chunk-PCPX42KL.js.map} +1 -1
- package/dist/{chunk-GW32KPCU.cjs → chunk-R24DI24X.cjs} +61 -2
- package/dist/chunk-R24DI24X.cjs.map +1 -0
- package/dist/{chunk-XVWCOTR6.js → chunk-SFQWJMKT.js} +7 -6
- package/dist/chunk-SFQWJMKT.js.map +1 -0
- package/dist/{chunk-6BKTCEUP.cjs → chunk-TY3TLZAW.cjs} +36 -2
- package/dist/chunk-TY3TLZAW.cjs.map +1 -0
- package/dist/{chunk-DM3LMRBC.js → chunk-UKPGSAZW.js} +187 -61
- package/dist/chunk-UKPGSAZW.js.map +1 -0
- package/dist/{chunk-NH2O2AUR.js → chunk-WC5FFSHB.js} +26 -4
- package/dist/chunk-WC5FFSHB.js.map +1 -0
- package/dist/{chunk-CLL7RUQV.cjs → chunk-WWOLFXTX.cjs} +40 -18
- package/dist/chunk-WWOLFXTX.cjs.map +1 -0
- package/dist/{chunk-JBSYC7BB.cjs → chunk-X2BWAZAU.cjs} +66 -53
- package/dist/chunk-X2BWAZAU.cjs.map +1 -0
- package/dist/{chunk-GOLDJNMZ.js → chunk-XBTEO4OB.js} +28 -5
- package/dist/chunk-XBTEO4OB.js.map +1 -0
- package/dist/{chunk-EPOXXJBK.js → chunk-YU2CUNFO.js} +3 -3
- package/dist/{chunk-EPOXXJBK.js.map → chunk-YU2CUNFO.js.map} +1 -1
- package/dist/constants.cjs +4 -4
- package/dist/constants.js +1 -1
- package/dist/engine.cjs +29 -30
- package/dist/engine.d.cts +6 -6
- package/dist/engine.d.ts +6 -6
- package/dist/engine.js +19 -20
- package/dist/format.cjs +7 -8
- package/dist/format.cjs.map +1 -1
- package/dist/format.js +2 -3
- package/dist/format.js.map +1 -1
- package/dist/index.cjs +28 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +20 -21
- package/dist/index.js.map +1 -1
- package/dist/language.cjs +74 -12
- package/dist/language.cjs.map +1 -1
- package/dist/language.d.cts +6 -6
- package/dist/language.d.ts +6 -6
- package/dist/language.js +68 -6
- package/dist/language.js.map +1 -1
- package/dist/lexer.cjs +19 -19
- package/dist/lexer.d.cts +3 -3
- package/dist/lexer.d.ts +3 -3
- package/dist/lexer.js +7 -7
- package/dist/normalizer.cjs +12 -12
- package/dist/normalizer.d.cts +4 -210
- package/dist/normalizer.d.ts +4 -210
- package/dist/normalizer.js +6 -6
- package/dist/packages.cjs +36 -37
- package/dist/packages.d.cts +5 -47
- package/dist/packages.d.ts +5 -47
- package/dist/packages.js +13 -14
- package/dist/parser.cjs +12 -12
- package/dist/parser.d.cts +3 -2
- package/dist/parser.d.ts +3 -2
- package/dist/parser.js +4 -4
- package/dist/resolvers.d.cts +1 -1
- package/dist/resolvers.d.ts +1 -1
- package/dist/uom.cjs +14 -14
- package/dist/uom.d.cts +12 -4
- package/dist/uom.d.ts +12 -4
- package/dist/uom.js +4 -4
- package/dist/vm.cjs +17 -17
- package/dist/vm.js +6 -6
- package/package.json +2 -1
- package/dist/NormalizerRule-BrVoVjmP.d.cts +0 -163
- package/dist/NormalizerRule-CEjf1FyD.d.ts +0 -163
- package/dist/chunk-34RRD7PC.js.map +0 -1
- package/dist/chunk-3PPFLFH4.js.map +0 -1
- package/dist/chunk-3YNVWKR2.cjs.map +0 -1
- package/dist/chunk-4QADQTWS.js.map +0 -1
- package/dist/chunk-5YEMOYSE.js.map +0 -1
- package/dist/chunk-64W6GLLZ.js.map +0 -1
- package/dist/chunk-6BKTCEUP.cjs.map +0 -1
- package/dist/chunk-6NTVRDQV.cjs.map +0 -1
- package/dist/chunk-C4XZV6E7.cjs.map +0 -1
- package/dist/chunk-CLL7RUQV.cjs.map +0 -1
- package/dist/chunk-DM3LMRBC.js.map +0 -1
- package/dist/chunk-EBSPLUW4.cjs.map +0 -1
- package/dist/chunk-EIGTWK5N.js.map +0 -1
- package/dist/chunk-GOLDJNMZ.js.map +0 -1
- package/dist/chunk-GW32KPCU.cjs.map +0 -1
- package/dist/chunk-HTXVVJRA.cjs.map +0 -1
- package/dist/chunk-HWSZJQCI.js.map +0 -1
- package/dist/chunk-J73SJHR3.cjs.map +0 -1
- package/dist/chunk-JBSYC7BB.cjs.map +0 -1
- package/dist/chunk-KVILKGMS.js.map +0 -1
- package/dist/chunk-LR7YASZF.cjs.map +0 -1
- package/dist/chunk-M5LX5AOO.js.map +0 -1
- package/dist/chunk-NH2O2AUR.js.map +0 -1
- package/dist/chunk-NMCRQP3Z.cjs.map +0 -1
- package/dist/chunk-NMD5VRN4.cjs.map +0 -1
- package/dist/chunk-OT6OJY7C.cjs +0 -114
- package/dist/chunk-OT6OJY7C.cjs.map +0 -1
- package/dist/chunk-QNJ4ACRT.cjs.map +0 -1
- package/dist/chunk-QWY3VEZN.js.map +0 -1
- package/dist/chunk-RFYD5TJE.js +0 -111
- package/dist/chunk-RFYD5TJE.js.map +0 -1
- package/dist/chunk-RIN643A3.js.map +0 -1
- package/dist/chunk-RZCWSXTA.cjs.map +0 -1
- package/dist/chunk-SDGRK7EP.js.map +0 -1
- package/dist/chunk-XJCMXB2E.cjs.map +0 -1
- package/dist/chunk-XVWCOTR6.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/language/TokenCategoryMap.ts"],"names":[],"mappings":";;;AAiBA,IAAM,kBAAA,GAAoD;AAAA;AAAA,EAEzD,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,KAAA,EAAO,QAAA;AAAA,EACP,MAAA,EAAQ,QAAA;AAAA;AAAA,EAGR,EAAA,EAAI,SAAA;AAAA,EACJ,CAAA,EAAG,SAAA;AAAA,EACH,GAAA,EAAK,SAAA;AAAA,EACL,KAAA,EAAO,SAAA;AAAA,EACP,QAAA,EAAU,SAAA;AAAA,EACV,SAAA,EAAW,SAAA;AAAA,EACX,IAAA,EAAM,SAAA;AAAA,EACN,MAAA,EAAQ,SAAA;AAAA,EACR,EAAA,EAAI,SAAA;AAAA,EACJ,YAAA,EAAc,SAAA;AAAA,EACd,aAAA,EAAe,SAAA;AAAA,EACf,cAAA,EAAgB,SAAA;AAAA,EAChB,aAAA,EAAe,SAAA;AAAA,EACf,aAAA,EAAe,SAAA;AAAA,EACf,eAAA,EAAiB,SAAA;AAAA,EACjB,eAAA,EAAiB,SAAA;AAAA,EACjB,IAAA,EAAM,SAAA;AAAA,EACN,IAAA,EAAM,SAAA;AAAA,EACN,KAAA,EAAO,SAAA;AAAA,EACP,KAAA,EAAO,SAAA;AAAA,EACP,O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Category } from \"@solve-js/language/TokenCategory\";\n\n/**\n * Static, built-in token-type → semantic-category table.\n *\n * Covers the full `TokenTypes` surface (see Token.ts) so nothing recognized\n * by the lexer's grammar goes uncategorized by omission. Structural/internal\n * token types (WS, NEWLINE, EOF, BACKTICK_OPEN, INLINE_SOLVE_START, COMMENT)\n * are intentionally absent, they're either filtered out before reaching\n * this lookup (see Lexer.getHighlightTokens) or simply have nothing\n * meaningful to highlight. COMMENT specifically: it reaches\n * Lexer.getHighlightTokens() (unlike WS/NEWLINE, filtered earlier), so a\n * future \"give comments their own color\" pass would add a real category\n * here. This is a rendering-scope decision, not a correctness\n * requirement, since COMMENT tokens are already filtered out of the\n * parser's input regardless of how they're highlighted.\n */\nconst TOKEN_CATEGORY_MAP: Record<string, TokenCategory> = {\n\t// Literals\n\tNUMBER: \"number\",\n\tBIGINT: \"number\",\n\tFLOAT: \"number\",\n\tSTRING: \"string\",\n\n\t// Keywords (constants, date words, dice, misc grammar keywords)\n\tPI: \"keyword\",\n\tE: \"keyword\",\n\tNOW: \"keyword\",\n\tTODAY: \"keyword\",\n\tTOMORROW: \"keyword\",\n\tYESTERDAY: \"keyword\",\n\tROLL: \"keyword\",\n\tGLOBAL: \"keyword\",\n\tOF: \"keyword\",\n\tDURATION_DAY: \"keyword\",\n\tDURATION_WEEK: \"keyword\",\n\tDURATION_MONTH: \"keyword\",\n\tDURATION_YEAR: \"keyword\",\n\tDURATION_HOUR: \"keyword\",\n\tDURATION_MINUTE: \"keyword\",\n\tDURATION_SECOND: \"keyword\",\n\tNEXT: \"keyword\",\n\tLAST: \"keyword\",\n\tUNTIL: \"keyword\",\n\tSINCE: \"keyword\",\n\tBETWEEN: \"keyword\",\n\tFROM: \"keyword\",\n\tBEST: \"keyword\",\n\tKEYWORD: \"keyword\",\n\tTRUE: \"keyword\",\n\tFALSE: \"keyword\",\n\tIF: \"keyword\",\n\tTHEN: \"keyword\",\n\tELSE: \"keyword\",\n\tAS: \"keyword\",\n\tCONVERTER_NAME: \"keyword\",\n\tROUNDED: \"keyword\",\n\tTO_NEAREST: \"keyword\",\n\tDECIMAL_PLACES: \"keyword\",\n\tAVERAGE_OF: \"keyword\",\n\tMEDIAN_OF: \"keyword\",\n\tTOTAL_OF: \"keyword\",\n\tCOUNT_OF: \"keyword\",\n\tLARGER_OF: \"keyword\",\n\tSMALLER_OF: \"keyword\",\n\tHALF_OF: \"keyword\",\n\tMIDPOINT_BETWEEN: \"keyword\",\n\tREMAINDER_OF: \"keyword\",\n\tNTH_ROOT: \"keyword\",\n\tLOG_PHRASE: \"keyword\",\n\tLOG_BASE: \"keyword\",\n\tGCD_OF: \"keyword\",\n\tLCM_OF: \"keyword\",\n\tSQUARE_ROOT_OF: \"keyword\",\n\tCUBE_ROOT_OF: \"keyword\",\n\tCLAMP: \"keyword\",\n\tMAP: \"keyword\",\n\tREDUCE: \"keyword\",\n\tSUM_FN: \"keyword\",\n\tPROD_FN: \"keyword\",\n\t// Symbolic algebra verbs (packages/symbolic/). Declared here alongside\n\t// map/reduce rather than only on the package descriptor, so highlighting is\n\t// correct without depending on registration order.\n\tEXPAND_FN: \"keyword\",\n\tFACTOR_FN: \"keyword\",\n\tSOLVE_FN: \"keyword\",\n\tDER_FN: \"keyword\",\n\tINTEGRAL_FN: \"keyword\",\n\tTAYLOR_FN: \"keyword\",\n\tJACOBIAN_FN: \"keyword\",\n\tIMAGINARY: \"number\",\n\tCONJ_FN: \"keyword\",\n\tRE_FN: \"keyword\",\n\tIM_FN: \"keyword\",\n\tCANCEL_FN: \"keyword\",\n\tAPART_FN: \"keyword\",\n\tTIME_IN: \"keyword\",\n\tDATE_IN: \"keyword\",\n\tTIME_DIFFERENCE_BETWEEN: \"keyword\",\n\tCITY_NAME: \"keyword\",\n\tOVER: \"keyword\",\n\t// The investment grammar's connectives (packages/finance/).\n\tAFTER: \"keyword\",\n\tPRESENT_VALUE_OF: \"keyword\",\n\tANNUAL_RETURN_ON: \"keyword\",\n\tFOR_DURATION: \"keyword\",\n\tCOMPOUNDING: \"keyword\",\n\tINVESTED: \"keyword\",\n\tRETURNED: \"keyword\",\n\tRATE_AT: \"keyword\",\n\tCOMPOUND_INTEREST_ON: \"keyword\",\n\tINTEREST_ON: \"keyword\",\n\tDAILY_REPAYMENT_ON: \"keyword\",\n\tMONTHLY_REPAYMENT_ON: \"keyword\",\n\tANNUAL_REPAYMENT_ON: \"keyword\",\n\tTOTAL_REPAYMENT_ON: \"keyword\",\n\tDAILY_LOAN_INTEREST_ON: \"keyword\",\n\tMONTHLY_LOAN_INTEREST_ON: \"keyword\",\n\tANNUAL_LOAN_INTEREST_ON: \"keyword\",\n\tTOTAL_LOAN_INTEREST_ON: \"keyword\",\n\tTAX_ON: \"keyword\",\n\tTAX_OFF: \"keyword\",\n\tTAX_IN_PHRASE: \"keyword\",\n\tIS_TO: \"keyword\",\n\tIS: \"keyword\",\n\tPCT_ON: \"operator\",\n\tPCT_OFF: \"operator\",\n\tOF_WHAT: \"keyword\",\n\tOFF_WHAT: \"keyword\",\n\tON_WHAT: \"keyword\",\n\tRANDOM_NUMBER: \"keyword\",\n\tWHAT_IS: \"keyword\",\n\tWHAT_WAS: \"keyword\",\n\tVALUE_OF: \"keyword\",\n\tWORTH_IN: \"keyword\",\n\tIN_YEAR_DOLLARS: \"keyword\",\n\tINGREDIENT_NAME: \"keyword\",\n\tASSUMING: \"keyword\",\n\t// Datetime, workdays/weekdays/timestamps (packages/datetime/); Time\n\t// video timecode (packages/time/). See Token.ts's TokenTypes doc\n\t// comments for why each is a fused phrase/sequence token rather than a\n\t// bare keyword.\n\tWORKDAYS_IN: \"keyword\",\n\tWEEKDAY_ON: \"keyword\",\n\tWEEKDAY_IN: \"keyword\",\n\tMONTH_ON: \"keyword\",\n\tMONTH_IN: \"keyword\",\n\tWEEK_ON: \"keyword\",\n\tDAYS_IN_PERIOD: \"keyword\",\n\tIN_TWO_UNITS: \"unit\",\n\tPER_UNIT: \"unit\",\n\tAT_RATE: \"keyword\",\n\tWEEK_IN: \"keyword\",\n\tBETWEEN_UNIT: \"keyword\",\n\tIS_WEEKEND: \"keyword\",\n\tIS_WORKDAY: \"keyword\",\n\tCURRENT_TIMESTAMP: \"keyword\",\n\tTO_DATE: \"keyword\",\n\tTO_TIMESTAMP: \"keyword\",\n\tVIDEO_TIMECODE: \"datetime\",\n\tFRAME_COUNT: \"datetime\",\n\tAT: \"keyword\",\n\n\t// Arithmetic / assignment-style operators\n\tPLUS: \"operator\",\n\t// The word \"and\". An operator rather than a keyword: it adds, and syntax\n\t// highlighting that painted it as a keyword would make \"5 and 3\" look\n\t// structurally different from \"5 + 3\" when the two mean the same thing.\n\tAND_CONJ: \"operator\",\n\tMINUS: \"operator\",\n\tSTAR: \"operator\",\n\tSLASH: \"operator\",\n\tCARET: \"operator\",\n\tPERCENT: \"operator\",\n\tLSHIFT: \"operator\",\n\tRSHIFT: \"operator\",\n\tEQUALS: \"operator\",\n\tTHEREFORE: \"operator\",\n\tINCREASE_BY: \"operator\",\n\tDECREASE_BY: \"operator\",\n\tOF_WHAT_IS: \"keyword\",\n\tON_WHAT_IS: \"keyword\",\n\tOFF_WHAT_IS: \"keyword\",\n\tTIMES_BY: \"operator\",\n\tMULTIPLY_BY: \"operator\",\n\tDIVIDE_BY: \"operator\",\n\tMOD: \"operator\",\n\tINCREASE: \"operator\",\n\tDECREASE: \"operator\",\n\tUNICODE_MATH: \"operator\",\n\tQUESTION: \"operator\",\n\tBANG: \"operator\",\n\n\t// Comparison operators\n\tNEQ: \"comparison\",\n\tIN: \"comparison\",\n\tGTE: \"comparison\",\n\tLTE: \"comparison\",\n\tEQUALITY: \"comparison\",\n\tLT: \"comparison\",\n\tGT: \"comparison\",\n\tLOGICAL_AND: \"comparison\",\n\tLOGICAL_OR: \"comparison\",\n\tOR: \"comparison\",\n\n\t// Bitwise operators\n\tURSHIFT: \"bitwise\",\n\tBIT_AND: \"bitwise\",\n\tBIT_OR: \"bitwise\",\n\tBIT_NOT: \"bitwise\",\n\tBIT_XOR: \"bitwise\",\n\n\t// Functions\n\tFUNC: \"function\",\n\n\t// Variable references/definitions, DOLLAR/COLON are the sigils, IDENT is\n\t// a bare identifier reference. All three are recognized-by-the-grammar\n\t// variable syntax at LEX time, independent of whether the variable turns\n\t// out to be defined at eval time (that's a separate, later concern).\n\tDOLLAR: \"variable\",\n\tCOLON: \"variable\",\n\tIDENT: \"variable\",\n\n\t// Units / conversions / currency symbols\n\tUNIT: \"unit\",\n\tCONVERT: \"unit\",\n\tTO: \"unit\",\n\tPOUND: \"unit\",\n\tEURO: \"unit\",\n\tYEN: \"unit\",\n\tRUBLE: \"unit\",\n\tWON: \"unit\",\n\tCURRENCY_SYMBOL: \"unit\",\n\n\t// Cross-line data access (packages/lines/)\n\tPREV: \"keyword\",\n\tLINE_REF: \"keyword\",\n\tSUM_RANGE_CALL: \"keyword\",\n\tAVERAGE_RANGE_CALL: \"keyword\",\n\tTOTAL_ABOVE: \"keyword\",\n\tSUM_ABOVE: \"keyword\",\n\tAVERAGE_ABOVE: \"keyword\",\n\n\t// Datetime literals/durations\n\tDATETIME_LITERAL: \"datetime\",\n\tDURATION: \"datetime\",\n\n\t// Vectors\n\tVEC2: \"vector\",\n\tVEC3: \"vector\",\n\tVEC4: \"vector\",\n\n\t// Punctuation, grouping/separators, deliberately neutral/muted rather\n\t// than left uncategorized: they're still recognized grammar, just not\n\t// semantically interesting enough to earn a \"loud\" color.\n\tLPAREN: \"punctuation\",\n\tRPAREN: \"punctuation\",\n\tLBRACKET: \"punctuation\",\n\tRBRACKET: \"punctuation\",\n\tLBRACE: \"punctuation\",\n\tRBRACE: \"punctuation\",\n\tDOT: \"punctuation\",\n\tCOMMA: \"punctuation\",\n\tSEMICOLON: \"punctuation\",\n\n\t// Errors\n\tERROR: \"error\",\n};\n\n/**\n * Token types intentionally left uncategorized, either purely structural\n * (never meant to be visibly styled) or already filtered out upstream\n * before reaching a category lookup. Used only by the completeness test to\n * distinguish \"deliberately unstyled\" from \"forgotten.\"\n */\nexport const UNCATEGORIZED_TOKEN_TYPES: ReadonlySet<string> = new Set([\n\t\"WS\",\n\t\"NEWLINE\",\n\t\"EOF\",\n\t\"BACKTICK_OPEN\",\n\t\"INLINE_SOLVE_START\",\n\t\"COMMENT\",\n]);\n\n/**\n * Runtime registry for package-contributed categories (e.g. a plugin's\n * custom token types). Overrides/extends the static table above, never\n * replaces it, so a package can't accidentally break core highlighting.\n * Register/unregister symmetry mirrors this codebase's other pluggable\n * registries (e.g. sharedOpRegistry). See ExpressionEngine.registerPackage\n * / unregisterPackage, which call these on behalf of IEnginePackage.tokenCategories.\n */\nconst pluginCategories = new Map<string, TokenCategory>();\n\n/**\n * Map a token type to a highlighting category.\n *\n * @param tokenType - Token type a package registered.\n * @param category - Category deciding how an editor colours it.\n */\nexport function registerTokenCategory(tokenType: string, category: TokenCategory): void {\n\tpluginCategories.set(tokenType, category);\n}\n\n/**\n * Remove a token type's highlighting category.\n *\n * @param tokenType - Token type to forget. Unknown types are ignored.\n */\nexport function unregisterTokenCategory(tokenType: string): void {\n\tpluginCategories.delete(tokenType);\n}\n\n/**\n * Resolve a token type to its semantic category, checking plugin-contributed\n * categories first (so a plugin could theoretically re-categorize a builtin\n * token type, though in practice plugins only ever add categories for their\n * own new types).\n *\n * @returns The category, or `undefined` if the token type has no category\n * the signal to a UI adapter that this token should render unstyled.\n */\nexport function getTokenCategory(tokenType: string): TokenCategory | undefined {\n\treturn pluginCategories.get(tokenType) ?? TOKEN_CATEGORY_MAP[tokenType];\n}\n"]}
|
|
@@ -1,6 +1,179 @@
|
|
|
1
1
|
import { createTimeoutSignal } from './chunk-Z4X2RWOF.js';
|
|
2
2
|
import { ErrorFactory } from './chunk-6RDSQURE.js';
|
|
3
3
|
|
|
4
|
+
// src/uom/Iso4217.ts
|
|
5
|
+
var ISO_4217_CODES = /* @__PURE__ */ new Set([
|
|
6
|
+
"AED",
|
|
7
|
+
"AFN",
|
|
8
|
+
"ALL",
|
|
9
|
+
"AMD",
|
|
10
|
+
"ANG",
|
|
11
|
+
"AOA",
|
|
12
|
+
"ARS",
|
|
13
|
+
"AUD",
|
|
14
|
+
"AWG",
|
|
15
|
+
"AZN",
|
|
16
|
+
"BAM",
|
|
17
|
+
"BBD",
|
|
18
|
+
"BDT",
|
|
19
|
+
"BGN",
|
|
20
|
+
"BHD",
|
|
21
|
+
"BIF",
|
|
22
|
+
"BMD",
|
|
23
|
+
"BND",
|
|
24
|
+
"BOB",
|
|
25
|
+
"BOV",
|
|
26
|
+
"BRL",
|
|
27
|
+
"BSD",
|
|
28
|
+
"BTN",
|
|
29
|
+
"BWP",
|
|
30
|
+
"BYN",
|
|
31
|
+
"BZD",
|
|
32
|
+
"CAD",
|
|
33
|
+
"CDF",
|
|
34
|
+
"CHE",
|
|
35
|
+
"CHF",
|
|
36
|
+
"CHW",
|
|
37
|
+
"CLF",
|
|
38
|
+
"CLP",
|
|
39
|
+
"CNY",
|
|
40
|
+
"COP",
|
|
41
|
+
"COU",
|
|
42
|
+
"CRC",
|
|
43
|
+
"CUP",
|
|
44
|
+
"CVE",
|
|
45
|
+
"CZK",
|
|
46
|
+
"DJF",
|
|
47
|
+
"DKK",
|
|
48
|
+
"DOP",
|
|
49
|
+
"DZD",
|
|
50
|
+
"EGP",
|
|
51
|
+
"ERN",
|
|
52
|
+
"ETB",
|
|
53
|
+
"EUR",
|
|
54
|
+
"FJD",
|
|
55
|
+
"FKP",
|
|
56
|
+
"GBP",
|
|
57
|
+
"GEL",
|
|
58
|
+
"GHS",
|
|
59
|
+
"GIP",
|
|
60
|
+
"GMD",
|
|
61
|
+
"GNF",
|
|
62
|
+
"GTQ",
|
|
63
|
+
"GYD",
|
|
64
|
+
"HKD",
|
|
65
|
+
"HNL",
|
|
66
|
+
"HTG",
|
|
67
|
+
"HUF",
|
|
68
|
+
"IDR",
|
|
69
|
+
"ILS",
|
|
70
|
+
"INR",
|
|
71
|
+
"IQD",
|
|
72
|
+
"IRR",
|
|
73
|
+
"ISK",
|
|
74
|
+
"JMD",
|
|
75
|
+
"JOD",
|
|
76
|
+
"JPY",
|
|
77
|
+
"KES",
|
|
78
|
+
"KGS",
|
|
79
|
+
"KHR",
|
|
80
|
+
"KMF",
|
|
81
|
+
"KPW",
|
|
82
|
+
"KRW",
|
|
83
|
+
"KWD",
|
|
84
|
+
"KYD",
|
|
85
|
+
"KZT",
|
|
86
|
+
"LAK",
|
|
87
|
+
"LBP",
|
|
88
|
+
"LKR",
|
|
89
|
+
"LRD",
|
|
90
|
+
"LSL",
|
|
91
|
+
"LYD",
|
|
92
|
+
"MAD",
|
|
93
|
+
"MDL",
|
|
94
|
+
"MGA",
|
|
95
|
+
"MKD",
|
|
96
|
+
"MMK",
|
|
97
|
+
"MNT",
|
|
98
|
+
"MOP",
|
|
99
|
+
"MRU",
|
|
100
|
+
"MUR",
|
|
101
|
+
"MVR",
|
|
102
|
+
"MWK",
|
|
103
|
+
"MXN",
|
|
104
|
+
"MXV",
|
|
105
|
+
"MYR",
|
|
106
|
+
"MZN",
|
|
107
|
+
"NAD",
|
|
108
|
+
"NGN",
|
|
109
|
+
"NIO",
|
|
110
|
+
"NOK",
|
|
111
|
+
"NPR",
|
|
112
|
+
"NZD",
|
|
113
|
+
"OMR",
|
|
114
|
+
"PAB",
|
|
115
|
+
"PEN",
|
|
116
|
+
"PGK",
|
|
117
|
+
"PHP",
|
|
118
|
+
"PKR",
|
|
119
|
+
"PLN",
|
|
120
|
+
"PYG",
|
|
121
|
+
"QAR",
|
|
122
|
+
"RON",
|
|
123
|
+
"RSD",
|
|
124
|
+
"RUB",
|
|
125
|
+
"RWF",
|
|
126
|
+
"SAR",
|
|
127
|
+
"SBD",
|
|
128
|
+
"SCR",
|
|
129
|
+
"SDG",
|
|
130
|
+
"SEK",
|
|
131
|
+
"SGD",
|
|
132
|
+
"SHP",
|
|
133
|
+
"SLE",
|
|
134
|
+
"SOS",
|
|
135
|
+
"SRD",
|
|
136
|
+
"SSP",
|
|
137
|
+
"STN",
|
|
138
|
+
"SVC",
|
|
139
|
+
"SYP",
|
|
140
|
+
"SZL",
|
|
141
|
+
"THB",
|
|
142
|
+
"TJS",
|
|
143
|
+
"TMT",
|
|
144
|
+
"TND",
|
|
145
|
+
"TOP",
|
|
146
|
+
"TRY",
|
|
147
|
+
"TTD",
|
|
148
|
+
"TWD",
|
|
149
|
+
"TZS",
|
|
150
|
+
"UAH",
|
|
151
|
+
"UGX",
|
|
152
|
+
"USD",
|
|
153
|
+
"USN",
|
|
154
|
+
"UYI",
|
|
155
|
+
"UYU",
|
|
156
|
+
"UYW",
|
|
157
|
+
"UZS",
|
|
158
|
+
"VED",
|
|
159
|
+
"VES",
|
|
160
|
+
"VND",
|
|
161
|
+
"VUV",
|
|
162
|
+
"WST",
|
|
163
|
+
"XAF",
|
|
164
|
+
"XCD",
|
|
165
|
+
"XCG",
|
|
166
|
+
"XOF",
|
|
167
|
+
"XPF",
|
|
168
|
+
"YER",
|
|
169
|
+
"ZAR",
|
|
170
|
+
"ZMW",
|
|
171
|
+
"ZWG"
|
|
172
|
+
]);
|
|
173
|
+
function isIso4217(code) {
|
|
174
|
+
return ISO_4217_CODES.has(code.toUpperCase());
|
|
175
|
+
}
|
|
176
|
+
|
|
4
177
|
// src/uom/CurrencyExchange.ts
|
|
5
178
|
var CurrencyErrorCodes = {
|
|
6
179
|
/** Frankfurter's rates endpoint returned a non-OK HTTP status. */
|
|
@@ -222,67 +395,20 @@ var _CurrencyExchangeService = class _CurrencyExchangeService {
|
|
|
222
395
|
// CURRENCY VALIDATION
|
|
223
396
|
// ------------------------------------------------------------------------
|
|
224
397
|
/**
|
|
225
|
-
* Check whether `code` is a recognized currency code
|
|
226
|
-
* cryptocurrencies in {@link CRYPTO_IDS}
|
|
227
|
-
*
|
|
398
|
+
* Check whether `code` is a recognized currency code: any active ISO 4217
|
|
399
|
+
* code, or one of the cryptocurrencies in {@link CRYPTO_IDS}.
|
|
400
|
+
*
|
|
401
|
+
* This used to be a hand-written list of forty-six codes, which meant
|
|
402
|
+
* `$100 in UAH` returned an unconverted hundred dollars rather than saying
|
|
403
|
+
* it could not convert. Answering from the standard rather than from
|
|
404
|
+
* whichever codes happened to get added is what stops that class of bug.
|
|
405
|
+
*
|
|
406
|
+
* Recognising a code is not the same as having a rate for it. That is
|
|
407
|
+
* answered later, by the exchange provider; conflating the two is what
|
|
408
|
+
* produced the silent failure.
|
|
228
409
|
*/
|
|
229
410
|
isCurrency(code) {
|
|
230
|
-
|
|
231
|
-
"USD",
|
|
232
|
-
"EUR",
|
|
233
|
-
"GBP",
|
|
234
|
-
"JPY",
|
|
235
|
-
"AUD",
|
|
236
|
-
"CAD",
|
|
237
|
-
"CHF",
|
|
238
|
-
"CNY",
|
|
239
|
-
"SEK",
|
|
240
|
-
"NOK",
|
|
241
|
-
"DKK",
|
|
242
|
-
"NZD",
|
|
243
|
-
"KRW",
|
|
244
|
-
"SGD",
|
|
245
|
-
"HKD",
|
|
246
|
-
"INR",
|
|
247
|
-
"BRL",
|
|
248
|
-
"ZAR",
|
|
249
|
-
"MXN",
|
|
250
|
-
"RUB",
|
|
251
|
-
"TRY",
|
|
252
|
-
"SAR",
|
|
253
|
-
"AED",
|
|
254
|
-
"ILS",
|
|
255
|
-
"PLN",
|
|
256
|
-
"CZK",
|
|
257
|
-
"HUF",
|
|
258
|
-
"THB",
|
|
259
|
-
"IDR",
|
|
260
|
-
"MYR",
|
|
261
|
-
"PHP",
|
|
262
|
-
"CLP",
|
|
263
|
-
"COP",
|
|
264
|
-
"ARS",
|
|
265
|
-
"NGN",
|
|
266
|
-
"EGP",
|
|
267
|
-
"PKR",
|
|
268
|
-
"BDT",
|
|
269
|
-
"VND",
|
|
270
|
-
"KES",
|
|
271
|
-
"MAD",
|
|
272
|
-
"QAR",
|
|
273
|
-
"KWD",
|
|
274
|
-
"OMR",
|
|
275
|
-
"BHD",
|
|
276
|
-
"JOD",
|
|
277
|
-
"BTC",
|
|
278
|
-
"ETH",
|
|
279
|
-
"SOL",
|
|
280
|
-
"XRP",
|
|
281
|
-
"ADA",
|
|
282
|
-
"DOGE",
|
|
283
|
-
"DOT"
|
|
284
|
-
];
|
|
285
|
-
return knownCurrencies.includes(code.toUpperCase());
|
|
411
|
+
return isIso4217(code) || this.isCryptoCode(code);
|
|
286
412
|
}
|
|
287
413
|
};
|
|
288
414
|
/**
|
|
@@ -325,5 +451,5 @@ var currencyExchangeService = new CurrencyExchangeService();
|
|
|
325
451
|
var sharedCurrencyExchange = currencyExchangeService;
|
|
326
452
|
|
|
327
453
|
export { CurrencyExchangeService, currencyExchangeService, sharedCurrencyExchange };
|
|
328
|
-
//# sourceMappingURL=chunk-
|
|
329
|
-
//# sourceMappingURL=chunk-
|
|
454
|
+
//# sourceMappingURL=chunk-UKPGSAZW.js.map
|
|
455
|
+
//# sourceMappingURL=chunk-UKPGSAZW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/uom/Iso4217.ts","../src/uom/CurrencyExchange.ts"],"names":[],"mappings":";;;;AAyBO,IAAM,cAAA,uBAA0C,GAAA,CAAI;AAAA,EAC1D,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAC/D,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAC/D,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EACnC,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;A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AAW,IAAA,EAAM,UAAA;AAAA,EAAY,GAAA,EAAK;AACzC,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA/BW,wBAAA,CAkDa,gBAAA,GAAmB,GAAA;AAlDtC,IAAM,uBAAA,GAAN;AAsTA,IAAM,uBAAA,GAA0B,IAAI,uBAAA;AAIpC,IAAM,sBAAA,GAAyB","file":"chunk-UKPGSAZW.js","sourcesContent":["/**\n * Every active ISO 4217 currency code.\n *\n * This exists because `CurrencyExchange.isCurrency()` used to hold a\n * hand-written list of forty-six codes, and a code missing from it did not\n * error: `$100 in UAH` returned the original hundred dollars, unconverted, as\n * though the rate were 1. A wrong answer, not a missing feature.\n *\n * The list is the ISO 4217 active set, so \"is this a currency\" is answered by\n * the standard rather than by whichever codes happened to get added. Whether a\n * *rate* is available for one is a separate question, answered at resolution\n * time by whatever the exchange provider supports; conflating the two is what\n * produced the silent failure.\n *\n * Deliberately excluded:\n * - The historical/withdrawn codes (DEM, FRF, and the rest). They are not\n * active, no provider quotes them, and recognising them would only move the\n * failure later.\n * - The X-series non-currencies: XAU/XAG/XPT/XPD (metals), XDR (IMF special\n * drawing rights), XTS (reserved for testing) and XXX (explicitly \"no\n * currency\"). XXX in particular must never resolve.\n *\n * Cryptocurrencies are not here either. They are not ISO 4217 and are tracked\n * separately in `CurrencyExchangeService.CRYPTO_IDS`.\n */\nexport const ISO_4217_CODES: ReadonlySet<string> = new Set([\n\t\"AED\", \"AFN\", \"ALL\", \"AMD\", \"ANG\", \"AOA\", \"ARS\", \"AUD\", \"AWG\", \"AZN\",\n\t\"BAM\", \"BBD\", \"BDT\", \"BGN\", \"BHD\", \"BIF\", \"BMD\", \"BND\", \"BOB\", \"BOV\",\n\t\"BRL\", \"BSD\", \"BTN\", \"BWP\", \"BYN\", \"BZD\",\n\t\"CAD\", \"CDF\", \"CHE\", \"CHF\", \"CHW\", \"CLF\", \"CLP\", \"CNY\", \"COP\", \"COU\",\n\t\"CRC\", \"CUP\", \"CVE\", \"CZK\",\n\t\"DJF\", \"DKK\", \"DOP\", \"DZD\",\n\t\"EGP\", \"ERN\", \"ETB\", \"EUR\",\n\t\"FJD\", \"FKP\",\n\t\"GBP\", \"GEL\", \"GHS\", \"GIP\", \"GMD\", \"GNF\", \"GTQ\", \"GYD\",\n\t\"HKD\", \"HNL\", \"HTG\", \"HUF\",\n\t\"IDR\", \"ILS\", \"INR\", \"IQD\", \"IRR\", \"ISK\",\n\t\"JMD\", \"JOD\", \"JPY\",\n\t\"KES\", \"KGS\", \"KHR\", \"KMF\", \"KPW\", \"KRW\", \"KWD\", \"KYD\", \"KZT\",\n\t\"LAK\", \"LBP\", \"LKR\", \"LRD\", \"LSL\", \"LYD\",\n\t\"MAD\", \"MDL\", \"MGA\", \"MKD\", \"MMK\", \"MNT\", \"MOP\", \"MRU\", \"MUR\", \"MVR\",\n\t\"MWK\", \"MXN\", \"MXV\", \"MYR\", \"MZN\",\n\t\"NAD\", \"NGN\", \"NIO\", \"NOK\", \"NPR\", \"NZD\",\n\t\"OMR\",\n\t\"PAB\", \"PEN\", \"PGK\", \"PHP\", \"PKR\", \"PLN\", \"PYG\",\n\t\"QAR\",\n\t\"RON\", \"RSD\", \"RUB\", \"RWF\",\n\t\"SAR\", \"SBD\", \"SCR\", \"SDG\", \"SEK\", \"SGD\", \"SHP\", \"SLE\", \"SOS\", \"SRD\",\n\t\"SSP\", \"STN\", \"SVC\", \"SYP\", \"SZL\",\n\t\"THB\", \"TJS\", \"TMT\", \"TND\", \"TOP\", \"TRY\", \"TTD\", \"TWD\", \"TZS\",\n\t\"UAH\", \"UGX\", \"USD\", \"USN\", \"UYI\", \"UYU\", \"UYW\", \"UZS\",\n\t\"VED\", \"VES\", \"VND\", \"VUV\",\n\t\"WST\",\n\t\"XAF\", \"XCD\", \"XCG\", \"XOF\", \"XPF\",\n\t\"YER\",\n\t\"ZAR\", \"ZMW\", \"ZWG\",\n]);\n\n/**\n * Whether `code` is an active ISO 4217 currency code.\n *\n * @param code - A three-letter code, in any case.\n */\nexport function isIso4217(code: string): boolean {\n\treturn ISO_4217_CODES.has(code.toUpperCase());\n}\n","/**\n * Production-grade currency exchange service with scalable architecture\n * Integrates with DataQueryService for worker-based execution\n */\n\nimport { isIso4217 } from \"@solve-js/uom/Iso4217\";\nimport { createTimeoutSignal } from \"@solve-js/utilities/TimeoutSignal\";\nimport { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\n\n/**\n * Error codes for this service. Co-located rather than unioned into\n * `errors/ErrorCode.ts`'s core catalog (that catalog is scoped to the\n * parser/VM/engine/errors/config/lexer layers, not yet the ~17 domain\n * packages. See that file's module doc for the intended per-package\n * pattern this follows).\n */\nexport const CurrencyErrorCodes = {\n /** Frankfurter's rates endpoint returned a non-OK HTTP status. */\n API_ERROR: \"CURRENCY_API_ERROR\",\n /** A requested currency/crypto code isn't in the fetched rate table, an unrecognized code, not an API failure. */\n UNKNOWN_CODE: \"UNKNOWN_CURRENCY_CODE\",\n /** CoinGecko's simple-price endpoint returned a non-OK HTTP status. */\n CRYPTO_API_ERROR: \"CRYPTO_PRICE_API_ERROR\",\n} as const;\n\n// ============================================================================\n// CURRENCY EXCHANGE SERVICE\n// ============================================================================\n\n/**\n * Caches exchange rates fetched from an external source.\n *\n * Rates are global market data rather than per-engine configuration, which is\n * why one instance is shared. Two engines with private copies would fetch the\n * same endpoint twice and could disagree about one pair at one moment. See\n * `engine/EngineContext.ts`.\n */\nexport class CurrencyExchangeService {\n /**\n * Live rate tables cached from successful getRate() fetches, keyed by\n * uppercase base currency. Each table holds every rate the API returned\n * for that base (plus the base itself at 1), so any pair whose two codes\n * appear in one fresh table can be served synchronously, including\n * cross pairs via triangulation (EUR→GBP through a USD-base table).\n * Stale tables are ignored, not evicted; the next successful fetch for\n * the same base overwrites them.\n */\n private baseTables: Map<string, { fetchedAt: number; rates: Record<string, number> }> = new Map();\n\n /**\n * How long a fetched rate may be served synchronously by getRateSync().\n * Beyond this window callers fall through to the async path (expression\n * shows Pending until the fetch lands).\n */\n private static readonly RATE_FRESHNESS_MS = 15 * 60 * 1000;\n\n /**\n * Ticker → CoinGecko coin id, for the cryptocurrencies `isCurrency()`\n * recognizes. Frankfurter (the fiat rate source below) is ECB reference\n * rates only and has no concept of BTC/ETH/etc, routing a crypto code\n * through it as `base=BTC` fails outright, which is why crypto pairs\n * previously never resolved (see CurrencyAsyncResolver/VM.ts's ADD\n * handling for the two bugs that let that failure pass silently instead\n * of surfacing as a real fetch).\n */\n private static readonly CRYPTO_IDS: Record<string, string> = {\n BTC: \"bitcoin\", ETH: \"ethereum\", SOL: \"solana\", XRP: \"ripple\",\n ADA: \"cardano\", DOGE: \"dogecoin\", DOT: \"polkadot\",\n };\n\n private isCryptoCode(code: string): boolean {\n return code.toUpperCase() in CurrencyExchangeService.CRYPTO_IDS;\n }\n\n constructor() {}\n\n // ------------------------------------------------------------------------\n // RATE FETCHING\n // ------------------------------------------------------------------------\n\n /**\n * Timeout (ms) for currency exchange rate fetches.\n *\n * If the frankfurter API doesn't respond within this window, the fetch\n * is aborted, preventing indefinite \"Pending\" states in the playground\n * and Obsidian plugin when the exchange rate API is unreachable.\n */\n private static readonly FETCH_TIMEOUT_MS = 10_000;\n\n /**\n * Fetch the live exchange rate for converting 1 unit of `from` into `to`.\n *\n * Routes cryptocurrency codes (see {@link CRYPTO_IDS}) to CoinGecko and\n * everything else to Frankfurter (ECB reference rates, fiat-only). On\n * success, caches the whole returned rate table for `from` so subsequent\n * lookups, including cross-pairs via triangulation, can be served\n * synchronously by {@link getRateSync} within the freshness window.\n *\n * @throws If the currency code is unrecognized or the fetch fails/times out.\n */\n async getRate(from: string, to: string, signal?: AbortSignal): Promise<number> {\n const fromUpper = from.toUpperCase();\n const toUpper = to.toUpperCase();\n\n if (this.isCryptoCode(fromUpper) || this.isCryptoCode(toUpper)) {\n return this.getCryptoRate(fromUpper, toUpper, signal);\n }\n\n // Combine the caller's optional abort signal with a hard timeout so a\n // hanging currency API never blocks re-evaluation indefinitely.\n const { signal: fetchSignal, cleanup } = createTimeoutSignal(\n signal,\n CurrencyExchangeService.FETCH_TIMEOUT_MS,\n \"Currency API fetch\",\n );\n\n try {\n const response = await fetch(`https://api.frankfurter.dev/v2/rates?base=${fromUpper}`, { signal: fetchSignal });\n if (!response.ok) throw ErrorFactory.external(CurrencyErrorCodes.API_ERROR, `Currency API returned ${response.status}`, { status: response.status });\n const data = await response.json();\n // The v2 endpoint returns a flat array of { date, base, quote, rate }\n // entries (one per target currency) rather than the classic v1 shape\n // { base, date, rates: { CODE: rate } }. Reading data.rates against\n // the real response is always undefined, so every conversion used to\n // throw \"Unknown currency\" no matter which currencies were requested.\n // Accept both shapes so a future API revision back to the object form\n // doesn't silently break this again.\n const rates: Record<string, number> = Array.isArray(data)\n ? Object.fromEntries(\n data\n .filter((entry: unknown): entry is { quote: string; rate: number } => {\n if (typeof entry !== \"object\" || entry === null) return false;\n const candidate = entry as { quote?: unknown; rate?: unknown };\n return typeof candidate.quote === \"string\" && typeof candidate.rate === \"number\";\n })\n .map((entry: { quote: string; rate: number }) => [entry.quote.toUpperCase(), entry.rate])\n )\n : (data.rates ?? {});\n if (rates[toUpper] === undefined) throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${toUpper}`, { code: toUpper });\n\n // The API returns ALL rates for the base currency, cache the whole\n // table so subsequent conversions (including cross pairs via\n // triangulation) resolve synchronously within the freshness window\n // instead of going Pending again.\n this.baseTables.set(fromUpper, {\n fetchedAt: Date.now(),\n rates: { ...rates, [fromUpper]: 1 },\n });\n\n return rates[toUpper];\n } finally {\n cleanup();\n }\n }\n\n /**\n * Crypto rate fetch, routed through CoinGecko's no-auth simple-price\n * endpoint instead of Frankfurter (fiat-only, has no BTC/ETH concept).\n * Handles all three combinations, crypto→crypto, crypto→fiat\n * fiat→crypto, via prices denominated in USD (or the target fiat\n * directly, which CoinGecko's `vs_currencies` also accepts), then\n * caches the result as a same-shaped base table so getRateSync /\n * convertSync keep working unchanged for crypto pairs too.\n */\n private async getCryptoRate(fromUpper: string, toUpper: string, signal?: AbortSignal): Promise<number> {\n const { signal: fetchSignal, cleanup } = createTimeoutSignal(\n signal,\n CurrencyExchangeService.FETCH_TIMEOUT_MS,\n \"Crypto price API fetch\",\n );\n\n try {\n const fromIsCrypto = this.isCryptoCode(fromUpper);\n const toIsCrypto = this.isCryptoCode(toUpper);\n let rate: number;\n\n if (fromIsCrypto && toIsCrypto) {\n const fromId = CurrencyExchangeService.CRYPTO_IDS[fromUpper];\n const toId = CurrencyExchangeService.CRYPTO_IDS[toUpper];\n const data = await this.fetchCoinGeckoPrices([fromId, toId], \"usd\", fetchSignal);\n const fromUsd = data[fromId]?.usd;\n const toUsd = data[toId]?.usd;\n if (typeof fromUsd !== \"number\") throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${fromUpper}`, { code: fromUpper });\n if (typeof toUsd !== \"number\") throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${toUpper}`, { code: toUpper });\n rate = fromUsd / toUsd;\n } else if (fromIsCrypto) {\n const fromId = CurrencyExchangeService.CRYPTO_IDS[fromUpper];\n const vs = toUpper.toLowerCase();\n const data = await this.fetchCoinGeckoPrices([fromId], vs, fetchSignal);\n const value = data[fromId]?.[vs];\n if (typeof value !== \"number\") throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${toUpper}`, { code: toUpper });\n rate = value;\n } else {\n const toId = CurrencyExchangeService.CRYPTO_IDS[toUpper];\n const vs = fromUpper.toLowerCase();\n const data = await this.fetchCoinGeckoPrices([toId], vs, fetchSignal);\n const priceOfToInFrom = data[toId]?.[vs];\n if (typeof priceOfToInFrom !== \"number\") throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${fromUpper}`, { code: fromUpper });\n rate = 1 / priceOfToInFrom;\n }\n\n // Cache as a single-pair base table, same shape Frankfurter fetches\n // produce, so getRateSync/convertSync's triangulation logic doesn't\n // need to know or care which source a rate came from.\n this.baseTables.set(fromUpper, {\n fetchedAt: Date.now(),\n rates: { [fromUpper]: 1, [toUpper]: rate },\n });\n\n return rate;\n } finally {\n cleanup();\n }\n }\n\n private async fetchCoinGeckoPrices(ids: string[], vsCurrency: string, signal: AbortSignal): Promise<Record<string, Record<string, number>>> {\n const url = `https://api.coingecko.com/api/v3/simple/price?ids=${ids.join(\",\")}&vs_currencies=${vsCurrency}`;\n const response = await fetch(url, { signal });\n if (!response.ok) throw ErrorFactory.external(CurrencyErrorCodes.CRYPTO_API_ERROR, `Crypto price API returned ${response.status}`, { status: response.status });\n return response.json();\n }\n\n /**\n * Seed a base rate table without a network fetch.\n *\n * Intended for tests and for future user-provided offline rates\n * production live data always comes from {@link getRate}. Seeded rates\n * obey the same freshness window as fetched ones.\n *\n * @param base - Base currency code (e.g. \"USD\").\n * @param rates - Map of currency code → rate relative to the base.\n */\n primeRates(base: string, rates: Record<string, number>): void {\n const baseUpper = base.toUpperCase();\n this.baseTables.set(baseUpper, {\n fetchedAt: Date.now(),\n rates: { ...rates, [baseUpper]: 1 },\n });\n }\n\n /**\n * Drop every cached/primed rate table.\n *\n * Mainly for test isolation: {@link sharedCurrencyExchange} is a\n * module-level singleton, so a rate primed or fetched by one test can\n * silently leak into a later test in the same file. Also usable in\n * production if a caller ever wants to force a full re-fetch.\n */\n clearRates(): void {\n this.baseTables.clear();\n }\n\n /**\n * Synchronous rate lookup: `1` for same-currency pairs, a cached LIVE\n * rate if one was fetched within {@link RATE_FRESHNESS_MS}, otherwise\n * `null`, callers fall through to the async fetch path and the\n * expression shows Pending until real data arrives.\n *\n * There is deliberately no hardcoded fallback table: a stale made-up\n * rate presented as a real conversion is worse than a Pending state.\n */\n getRateSync(from: string, to: string): number | null {\n const fromUpper = from.toUpperCase();\n const toUpper = to.toUpperCase();\n if (fromUpper === toUpper) {\n return 1;\n }\n const now = Date.now();\n for (const table of this.baseTables.values()) {\n if (now - table.fetchedAt > CurrencyExchangeService.RATE_FRESHNESS_MS) continue;\n const fromRate = table.rates[fromUpper];\n const toRate = table.rates[toUpper];\n if (fromRate && toRate) {\n return toRate / fromRate;\n }\n }\n return null;\n }\n\n /** Convert `value` from `from` to `to` using a freshly-fetched live rate (see {@link getRate}). */\n async convert(value: number, from: string, to: string): Promise<number> {\n const rate = await this.getRate(from, to);\n return value * rate;\n }\n\n /**\n * Get all currently cached fresh rates, keyed \"FROM:TO\".\n * @returns Snapshot of fresh live rates, or null when none are cached.\n */\n getAllRates(): Record<string, number> | null {\n const now = Date.now();\n const snapshot: Record<string, number> = {};\n let any = false;\n for (const [base, table] of this.baseTables) {\n if (now - table.fetchedAt > CurrencyExchangeService.RATE_FRESHNESS_MS) continue;\n for (const [code, rate] of Object.entries(table.rates)) {\n snapshot[`${base}:${code}`] = rate;\n any = true;\n }\n }\n return any ? snapshot : null;\n }\n\n /**\n * Check whether any fresh live rates are currently cached.\n */\n hasRates(): boolean {\n return this.getAllRates() !== null;\n }\n\n /**\n * Synchronous conversion using cached rates only\n * Returns null if rate not in cache\n */\n convertSync(value: number, from: string, to: string): number | null {\n const rate = this.getRateSync(from, to);\n if (rate === null) return null;\n return value * rate;\n }\n\n // ------------------------------------------------------------------------\n // CURRENCY VALIDATION\n // ------------------------------------------------------------------------\n\n /**\n * Check whether `code` is a recognized currency code: any active ISO 4217\n * code, or one of the cryptocurrencies in {@link CRYPTO_IDS}.\n *\n * This used to be a hand-written list of forty-six codes, which meant\n * `$100 in UAH` returned an unconverted hundred dollars rather than saying\n * it could not convert. Answering from the standard rather than from\n * whichever codes happened to get added is what stops that class of bug.\n *\n * Recognising a code is not the same as having a rate for it. That is\n * answered later, by the exchange provider; conflating the two is what\n * produced the silent failure.\n */\n isCurrency(code: string): boolean {\n return isIso4217(code) || this.isCryptoCode(code);\n }\n}\n\n// ============================================================================\n// SINGLETON INSTANCE\n// ============================================================================\n\n/** The shared rate cache. See {@link CurrencyExchangeService} for why it is shared. */\nexport const currencyExchangeService = new CurrencyExchangeService();\n\n// Export for backward compatibility\n/** Alias for {@link currencyExchangeService}, kept for older imports. */\nexport const sharedCurrencyExchange = currencyExchangeService;\n\n// Default export\nexport default currencyExchangeService;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UNIT_TABLE, UNIT_DIFFERENCES, EXTENDED_UNITS, MEASURE_KIND_NAMES, MEASURE_SYMBOLS, BEST_UNITS_METRIC } from './chunk-
|
|
1
|
+
import { UNIT_TABLE, UNIT_DIFFERENCES, EXTENDED_UNITS, MEASURE_KIND_NAMES, MEASURE_SYMBOLS, BEST_UNITS_METRIC } from './chunk-PCPX42KL.js';
|
|
2
2
|
|
|
3
3
|
// src/uom/UnitConversion.ts
|
|
4
4
|
var UNIT_LOOKUP = new Map(Object.entries(UNIT_TABLE));
|
|
@@ -93,7 +93,14 @@ function canConvert(from, to) {
|
|
|
93
93
|
if (fromExtended !== void 0 && toExtended !== void 0) {
|
|
94
94
|
return fromExtended.measure === toExtended.measure;
|
|
95
95
|
}
|
|
96
|
-
return
|
|
96
|
+
return bridgesToBaseMeasure(from, to) || bridgesToBaseMeasure(to, from);
|
|
97
|
+
}
|
|
98
|
+
function bridgesToBaseMeasure(extendedUnit, baseUnit) {
|
|
99
|
+
const extended = EXTENDED_UNITS[extendedUnit];
|
|
100
|
+
if (extended === void 0) return false;
|
|
101
|
+
const base = lookupUnit(resolveUnit(baseUnit));
|
|
102
|
+
if (base === void 0) return false;
|
|
103
|
+
return MEASURE_KIND_NAMES[base[0]] === extended.measure;
|
|
97
104
|
}
|
|
98
105
|
function convertUnit(value, from, to) {
|
|
99
106
|
if (from === to) return value;
|
|
@@ -116,8 +123,23 @@ function convertUnit(value, from, to) {
|
|
|
116
123
|
if (fExt !== void 0 && tExt !== void 0) {
|
|
117
124
|
return value * (fExt.toBase / tExt.toBase);
|
|
118
125
|
}
|
|
126
|
+
if (fExt !== void 0 && bridgesToBaseMeasure(from, to)) {
|
|
127
|
+
return convertRaw(value * fExt.toBase, baseUnitFor(to), to);
|
|
128
|
+
}
|
|
129
|
+
if (tExt !== void 0 && bridgesToBaseMeasure(to, from)) {
|
|
130
|
+
return convertRaw(value, from, baseUnitFor(from)) / tExt.toBase;
|
|
131
|
+
}
|
|
119
132
|
return convertRaw(value, from, to);
|
|
120
133
|
}
|
|
134
|
+
function baseUnitFor(unit) {
|
|
135
|
+
const entry = lookupUnit(resolveUnit(unit));
|
|
136
|
+
if (entry === void 0) return unit;
|
|
137
|
+
for (const symbol of Object.keys(UNIT_TABLE)) {
|
|
138
|
+
const candidate = UNIT_TABLE[symbol];
|
|
139
|
+
if (candidate[0] === entry[0] && candidate[1] === 1) return symbol;
|
|
140
|
+
}
|
|
141
|
+
return unit;
|
|
142
|
+
}
|
|
121
143
|
function getConvertiblePossibilities(unit) {
|
|
122
144
|
const resolved = resolveUnit(unit);
|
|
123
145
|
const entry = lookupUnit(resolved);
|
|
@@ -142,5 +164,5 @@ function getBestUnit(value, unit) {
|
|
|
142
164
|
}
|
|
143
165
|
|
|
144
166
|
export { canConvert, convertUnit, getBestUnit, getConvertiblePossibilities, getMeasure, isConvertibleUnit, isWorkdayUnit, resolveUnit };
|
|
145
|
-
//# sourceMappingURL=chunk-
|
|
146
|
-
//# sourceMappingURL=chunk-
|
|
167
|
+
//# sourceMappingURL=chunk-WC5FFSHB.js.map
|
|
168
|
+
//# sourceMappingURL=chunk-WC5FFSHB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/uom/UnitConversion.ts","../src/uom/UomConverter.ts"],"names":[],"mappings":";;;AAmCA,IAAM,cAA8C,IAAI,GAAA,CAAI,MAAA,CAAO,OAAA,CAAQ,UAAU,CAAC,CAAA;AAStF,IAAM,oBAAiD,IAAI,GAAA,CAAI,MAAA,CAAO,OAAA,CAAQ,gBAAgB,CAAC,CAAA;AAgBxF,SAAS,WAAW,IAAA,EAAqC;AAC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AAO,MAAA,CAAO,QAAA,EAAU,IAAA,EAAM,OAAO,IAAA,EAAK;AAAA,EACrD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAE,KAAA,EAAO,IAAA,EAAM,CAAA,EAAE;AAAA,EAC1B;AACF","file":"chunk-WC5FFSHB.js","sourcesContent":["/**\n * The unit conversion algorithm, ported from the `convert` npm package v7.0.2\n * alongside its tables (see `generated/UnitTable.generated.ts` and\n * THIRD-PARTY-NOTICES.md).\n *\n * Transliterated expression for expression rather than rewritten. Floating\n * point is not associative, so `(q + d) * (a / b) - d2` and any algebraically\n * equal rearrangement disagree in the last bits. Those bits are observable:\n * `0.5 l` best-converts to `500.00000000000006 mL` today, and the test suite\n * pins several conversions to ten decimal places.\n *\n * This module is deliberately unaware of the engine's own additions. Workdays,\n * extended units, currency and the caches all live in `UomConverter.ts`, which\n * layers them on top of these three functions.\n */\n\nimport {\n UNIT_TABLE,\n UNIT_DIFFERENCES,\n BEST_UNITS_METRIC,\n type UnitEntry,\n} from \"./generated/UnitTable.generated\";\n\n/**\n * The generated tables re-keyed into Maps once at module load.\n *\n * Not a micro-optimization. A 1456-key object literal lands in V8's dictionary\n * mode, and guarding a read on it against inherited names (`constructor`,\n * `toString`) costs about 123ns per call with either `hasOwnProperty.call` or\n * `Object.hasOwn`, measured. `Map.get` is about 6ns and needs no guard at all,\n * because a Map has no prototype chain to fall through to. That is a 20x\n * difference on the single hottest operation in the unit system: `convertRaw`\n * performs two of these per call, and `LanguageService` sweeps all 1456 keys\n * to build completions.\n */\nconst UNIT_LOOKUP: ReadonlyMap<string, UnitEntry> = new Map(Object.entries(UNIT_TABLE));\n\n/**\n * Temperature offsets, as a Map for the same reason.\n *\n * Also removes a latent hazard: the upstream code tests membership with `in`,\n * and `\"toString\" in UNIT_DIFFERENCES` is true, so an inherited name reaching\n * that branch would add a function to a number.\n */\nconst DIFFERENCE_LOOKUP: ReadonlyMap<string, number> = new Map(Object.entries(UNIT_DIFFERENCES));\n\n/**\n * Looks up a unit spelling.\n *\n * @returns its `[kind, ratio]` entry, or `undefined` if the spelling is not a\n * unit. Case-sensitive: no normalization or aliasing happens anywhere in this\n * module.\n *\n * The one deliberate deviation from upstream. `convert` tests membership with\n * `in` and reads the property directly, so inherited names like \"constructor\"\n * and \"toString\" reach its measure comparison and fail there with \"Cannot\n * convert between different measures\" instead of \"is not a valid unit\". Both\n * throw a RangeError and both report no measure, so nothing downstream can\n * tell the difference, and naming the real problem is the better message.\n */\nexport function lookupUnit(unit: string): UnitEntry | undefined {\n return UNIT_LOOKUP.get(unit);\n}\n\n/**\n * Converts `quantity` from one unit to another.\n *\n * THROWS a `RangeError` for an unknown unit or a pair in different measures.\n * Callers depend on that: `VM.ts`'s `extractDurationMs()` calls this with an\n * arbitrary unit inside a bare try/catch and treats the throw as \"not a\n * duration, contribute zero\". Returning NaN or the input unchanged instead\n * would turn `<date> + 5 kg` into an Invalid Date rather than a no-op.\n */\nexport function convertRaw(quantity: number, from: string, to: string): number {\n const parsedFrom = UNIT_LOOKUP.get(from);\n if (parsedFrom === undefined) {\n throw new RangeError(`${from} is not a valid unit`);\n }\n\n const parsedTo = UNIT_LOOKUP.get(to);\n if (parsedTo === undefined) {\n throw new RangeError(`${to} is not a valid unit`);\n }\n\n return convertResolved(quantity, from, to, parsedFrom, parsedTo);\n}\n\n/**\n * The conversion arithmetic, for callers that have already looked both units\n * up and want to skip doing it twice.\n *\n * Split out for `UomConverter.convertUnit()`, which has to check whether\n * either side is a workday or an extended unit before it can dispatch, and\n * would otherwise resolve each unit once to decide and again to convert. The\n * entries MUST be the ones this module returned for these exact spellings.\n */\nexport function convertResolved(\n quantity: number,\n from: string,\n to: string,\n fromEntry: UnitEntry,\n toEntry: UnitEntry\n): number {\n const parsedFrom = fromEntry;\n const parsedTo = toEntry;\n\n if (parsedFrom[0] !== parsedTo[0]) {\n // DELIBERATE DEVIATION from the ported original, which silently reinterpreted\n // \"m\" as minutes whenever the other side was a time unit. That is a guess,\n // and this project's stated position is that refusing to guess is the safer\n // default for a tool doing arithmetic on someone's real numbers (see\n // docs/architecture/design-decisions.md). The guess was not harmless: it\n // reached `<date> + <duration>` through VM.ts's extractDurationMs(), where\n // `today + 5 m` silently added five MINUTES for someone who wrote metres.\n //\n // Minutes are spelled \"min\", \"minute\" or \"minutes\", all of which the table\n // has always accepted.\n throw new RangeError(`Cannot convert between different measures: ${from} and ${to}`);\n }\n\n const fromRatio = parsedFrom[1];\n const toRatio = parsedTo[1];\n\n // Only six units in the whole table carry an offset, so the common path is\n // both misses. Reading the Map once per side and reusing the value beats\n // testing membership and then reading it again.\n const fromDifference = DIFFERENCE_LOOKUP.get(from);\n const toDifference = DIFFERENCE_LOOKUP.get(to);\n\n // Scales that do not share an origin (temperature) need the offset applied\n // around the ratio. Do not refactor the four branches into one expression:\n // the grouping is what makes the result bit-identical to the original.\n if (fromDifference !== undefined) {\n if (toDifference !== undefined) {\n return (quantity + fromDifference) * (fromRatio / toRatio) - toDifference;\n }\n return (quantity + fromDifference) * (fromRatio / toRatio);\n }\n\n if (toDifference !== undefined) {\n return quantity * (fromRatio / toRatio) - toDifference;\n }\n\n return quantity * (fromRatio / toRatio);\n}\n\n/**\n * Picks the most readable metric unit for a magnitude and converts to it.\n *\n * Only the metric lists are ported; nothing has ever requested the imperial\n * ones. Note the final conversion goes from the ORIGINAL unit to the chosen\n * one directly rather than via the smallest unit, which is what keeps the\n * result exact.\n */\nexport function convertToBestMetric(\n quantity: number,\n from: string\n): { quantity: number; unit: string } {\n const parsedFrom = UNIT_LOOKUP.get(from);\n if (parsedFrom === undefined) {\n throw new RangeError(`${from} is not a valid unit`);\n }\n\n const best = BEST_UNITS_METRIC[parsedFrom[0]];\n const smallestUnit = best[0][0];\n let bestUnit = smallestUnit;\n\n const baseQuantity = convertRaw(quantity, from, smallestUnit);\n const absQuantity = baseQuantity < 0 ? -baseQuantity : baseQuantity;\n\n // Thresholds are expressed in the smallest unit and ascend, so the last one\n // the magnitude reaches wins. Breaking early rather than scanning the whole\n // list matters for zero and for negatives, which stay on the smallest unit.\n for (let i = 0; i < best.length; i++) {\n const bestEntry = best[i];\n if (absQuantity >= bestEntry[1]) {\n bestUnit = bestEntry[0];\n } else {\n break;\n }\n }\n\n return { quantity: convertRaw(quantity, from, bestUnit), unit: bestUnit };\n}\n","/**\n * UoM Converter, built on the in-house unit tables in `UnitConversion.ts` and\n * `generated/UnitTable.generated.ts` (ported from the `convert` npm package\n * v7.0.2 so the engine ships with no runtime dependencies).\n *\n * Units are strictly case-sensitive and are looked up without aliasing. No unit\n * remapping, what you type is what you get.\n * e.g. 'C' = Celsius, 'c' = cup; 'MB' = megabytes, 'mb' = millibits.\n *\n * This file owns everything the base tables do not: the workday shim, the\n * extended (custom-measure) units, and the two caches.\n */\n\nimport { lookupUnit, convertRaw, convertResolved, convertToBestMetric } from \"@solve-js/uom/UnitConversion\";\nimport { MEASURE_KIND_NAMES, MEASURE_SYMBOLS, UNIT_TABLE } from \"@solve-js/uom/generated/UnitTable.generated\";\nimport { EXTENDED_UNITS } from \"@solve-js/uom/ExtendedUnits\";\n\n// ── \"workday\", a synthetic unit with no entry in the base table ───────────\n//\n// A business day (Mon-Fri) backing the datetime package's `<date> + N\n// workdays` arithmetic and `$X/workday` Rate literals\n// (packages/datetime/). NOT a real physical unit, a business day has no\n// fixed duration, since it depends on which calendar dates are weekends\n// so the ported base table has no concept of it and can't be\n// taught one without monkey-patching its internal unit table.\n//\n// For RATE-MATH purposes only (e.g. \"$500/workday x 4 weeks\" needs a\n// workday count to multiply by), a workday is treated as a FIXED 7/5 of a\n// calendar day: 5 workdays span exactly 7 calendar days in a whole week,\n// so this ratio is exact for whole-week spans and a reasonable linear\n// approximation otherwise. This is deliberately NOT the same\n// calendar-aware, weekend-skipping logic real \"<date> + N workdays\" date\n// arithmetic needs (see vm/VM.ts's addBusinessDays()), that can't be\n// reduced to a fixed ratio, since the exact skip pattern depends on which\n// day of the week the calculation actually starts from.\n//\n// Handled here as a thin pre/post layer in front of the normal\n// base-table path (rather than inside the tables themselves) so every\n// caller of getMeasure()/convertUnit()/canConvert() automatically gets\n// workday support for free.\nconst WORKDAY_UNIT_NAMES = new Set([\"workday\", \"workdays\"]);\nconst WORKDAY_TO_DAY_FACTOR = 7 / 5; // 1 workday == 1.4 calendar days\n\n/** Whether `unit` is the synthetic \"workday\" unit (see module note above). */\nexport function isWorkdayUnit(unit: string | undefined): unit is string {\n return typeof unit === \"string\" && WORKDAY_UNIT_NAMES.has(unit);\n}\n\n/**\n * Validate `unit` against the known unit table.\n *\n * @returns `unit` unchanged in all cases. This does NOT normalize casing\n * or aliasing (units are strictly case-sensitive, see the module note\n * above). A unit the table doesn't recognize is still\n * returned as-is (not thrown), so callers must not assume a returned\n * string is actually convertible, check with {@link isConvertibleUnit}\n * or {@link canConvert} first if that matters.\n *\n * Kept as an identity function purely for API compatibility. It used to guard\n * a validity cache, which existed because validating a unit meant a\n * throw/catch round trip through the old dependency. Validation is now a Map\n * lookup, so the cache cost more than it saved: worse, it was capped at 1000\n * entries against a 1456-unit table, so any sweep over the full vocabulary\n * (which is exactly what LanguageService does to build completions) evicted\n * on almost every call. That one change took the full-table sweep from 7.7ms\n * to under 20us.\n */\nexport function resolveUnit(unit: string): string {\n return unit;\n}\n\n// MEASURE_KIND_NAMES now comes from the generated table (it is derived data,\n// so the generator emits it rather than it being retyped here). The reason it\n// is a module-level constant has not changed: getMeasure() runs at least twice\n// per conversion, and this used to be reallocated on every call.\n\n/**\n * Get the measure/dimension kind for `unit` (e.g. `\"length\"`, `\"mass\"`,\n * `\"temperature\"`), used to check whether two units are even in the same\n * dimension before attempting a conversion.\n *\n * @returns `undefined` if `unit` isn't recognized, rather than throwing.\n */\nexport function getMeasure(unit: string): string | undefined {\n // Workday is a Time-measure unit by convention (see isWorkdayUnit's doc\n // comment) and is not in the base table, so resolve its measure via \"day\"\n // instead of attempting the real lookup below.\n if (isWorkdayUnit(unit)) return getMeasure(\"day\");\n\n // Extended (custom) categories the base table has no measure kind for,\n // see ExtendedUnits.ts.\n const extended = EXTENDED_UNITS[unit];\n if (extended) return extended.measure;\n\n const entry = lookupUnit(unit);\n if (entry === undefined) return undefined;\n\n return MEASURE_KIND_NAMES[entry[0]];\n}\n\n/**\n * Check whether `from` can be converted to `to`. Same unit, or same\n * measure kind (length, mass, ...) and the underlying tables accept the pair.\n * Never throws; returns `false` on any failure.\n */\nexport function canConvert(from: string, to: string): boolean {\n if (from === to) return true;\n if (isWorkdayUnit(from) || isWorkdayUnit(to)) {\n const fromMeasure = getMeasure(from);\n const toMeasure = getMeasure(to);\n return !!fromMeasure && fromMeasure === toMeasure;\n }\n // One table read per side, comparing numeric kind ids. The old shape called\n // getMeasure() on each side (two more reads) purely to compare the resulting\n // STRINGS, then did a throwaway conversion to confirm what the kind check had\n // already established.\n const fromEntry = lookupUnit(from);\n const toEntry = lookupUnit(to);\n if (fromEntry !== undefined && toEntry !== undefined) {\n return fromEntry[0] === toEntry[0];\n }\n\n // Extended (custom) categories aren't in the base table at all, so they are\n // compared on their own measure names instead.\n const fromExtended = EXTENDED_UNITS[from];\n const toExtended = EXTENDED_UNITS[to];\n if (fromExtended !== undefined && toExtended !== undefined) {\n return fromExtended.measure === toExtended.measure;\n }\n\n // Mixed: one side is in the base table and the other is extended. That used\n // to be refused outright, on the grounds that the two measure spaces are\n // disjoint. They are not, once an extended unit names a measure the base\n // table also has: `furlong` is a length and so is `m`, and the ratio between\n // them is exactly what both tables already record.\n return bridgesToBaseMeasure(from, to) || bridgesToBaseMeasure(to, from);\n}\n\n/**\n * Whether `extendedUnit` extends a measure the base table also knows, so a\n * value in it can reach `baseUnit`.\n *\n * The bridge works because both tables express a unit as a ratio to the same\n * physical base: the generated table's length ratios are metres and its mass\n * ratios are grams, and an extended unit declaring `measure: \"length\"` states\n * its `toBase` in the same metres. Composing the two ratios is then ordinary\n * arithmetic rather than a second conversion system.\n *\n * A measure the base table has no concept of, such as pace, still fails here,\n * which is the behaviour this replaced and the reason the check is by measure\n * name rather than by presence in the extended table.\n */\nfunction bridgesToBaseMeasure(extendedUnit: string, baseUnit: string): boolean {\n const extended = EXTENDED_UNITS[extendedUnit];\n if (extended === undefined) return false;\n\n const base = lookupUnit(resolveUnit(baseUnit));\n if (base === undefined) return false;\n\n return MEASURE_KIND_NAMES[base[0]] === extended.measure;\n}\n\n/**\n * Convert `value` from unit `from` to unit `to`.\n *\n * Does not validate that the conversion is possible, callers should check\n * with {@link canConvert} first if `from`/`to` aren't already known-good.\n *\n * THROWS a RangeError for an unknown unit or a cross-measure pair. `VM.ts`'s\n * `extractDurationMs()` depends on that, see {@link convertRaw}.\n *\n * This used to memoize a per-pair conversion factor in an LFU cache. The cache\n * is gone: computing the factor is now two Map reads, while the cache cost a\n * template-string key allocation on every call plus the LFU's own frequency\n * bookkeeping, so it was slower than the work it avoided. Removing it is\n * bit-exact, not merely close: the cache stored `convertRaw(1, f, t)`, which is\n * exactly `fromRatio / toRatio`, and then multiplied, which is the identical\n * expression `convertRaw(value, f, t)` evaluates. It also deleted the special\n * case that existed only to keep offset-based temperature pairs out of a\n * factor cache.\n */\nexport function convertUnit(value: number, from: string, to: string): number {\n if (from === to) return value;\n\n // Fast path first: two ordinary units, which is nearly every call. Resolving\n // both here and handing the entries to convertResolved() avoids looking them\n // up again inside convertRaw(). Neither workdays nor extended units appear in\n // the base table, so they always fall through to the branches below and this\n // ordering cannot steal a case from them. UnitVocabulary.spec.ts pins that\n // the two vocabularies stay disjoint.\n const fromEntry = lookupUnit(from);\n const toEntry = lookupUnit(to);\n if (fromEntry !== undefined && toEntry !== undefined) {\n return convertResolved(value, from, to, fromEntry, toEntry);\n }\n\n // Workday <-> any other Time-measure unit: pivot through \"day\" using the\n // fixed 7/5 ratio (see isWorkdayUnit's doc comment above).\n if (isWorkdayUnit(from) && isWorkdayUnit(to)) return value; // \"workday\" <-> \"workdays\" alias\n if (isWorkdayUnit(from)) {\n const days = value * WORKDAY_TO_DAY_FACTOR;\n return to === \"day\" ? days : convertUnit(days, \"day\", to);\n }\n if (isWorkdayUnit(to)) {\n const days = from === \"day\" ? value : convertUnit(value, from, \"day\");\n return days / WORKDAY_TO_DAY_FACTOR;\n }\n\n // Extended (custom) categories the base table has no measure kind for\n // (see ExtendedUnits.ts), compute the ratio directly from each unit's\n // factor-to-base value instead of calling convertRaw(), which would throw\n // on an unrecognized unit string. Every extended category is a pure linear\n // ratio scale (no Temperature-style offset), so this is always safe.\n const fExt = EXTENDED_UNITS[from];\n const tExt = EXTENDED_UNITS[to];\n if (fExt !== undefined && tExt !== undefined) {\n return value * (fExt.toBase / tExt.toBase);\n }\n\n // One side extended, the other in the base table, sharing a measure. Convert\n // through the measure's base unit, which both tables state their ratios\n // against: an extended length declares its `toBase` in metres, and the\n // generated table's length ratios are metres too.\n if (fExt !== undefined && bridgesToBaseMeasure(from, to)) {\n return convertRaw(value * fExt.toBase, baseUnitFor(to), to);\n }\n if (tExt !== undefined && bridgesToBaseMeasure(to, from)) {\n return convertRaw(value, from, baseUnitFor(from)) / tExt.toBase;\n }\n\n // Offsets, cross-measure rejection and the unknown-unit throw all live in\n // convertRaw. Nothing is layered on top here any more.\n return convertRaw(value, from, to);\n}\n\n/**\n * The unit a measure states its ratios against, found from any unit in it.\n *\n * Read out of the table rather than hard-coded, so it cannot drift from the\n * ratios it has to agree with: the base is whichever unit of that measure has\n * a ratio of exactly one.\n */\nfunction baseUnitFor(unit: string): string {\n const entry = lookupUnit(resolveUnit(unit));\n if (entry === undefined) return unit;\n\n for (const symbol of Object.keys(UNIT_TABLE)) {\n const candidate = UNIT_TABLE[symbol];\n if (candidate[0] === entry[0] && candidate[1] === 1) return symbol;\n }\n return unit;\n}\n\n/**\n * List every unit symbol in the same measure/dimension as `unit` (wiki:\n * Units-Of-Measurement, \"Conversion Possibilities\", `sourceUnit to ?`\n * e.g. `cm to ?\"` → every Length unit). Excludes `unit` itself.\n *\n * Reads MEASURE_SYMBOLS, which is a curated symbols-only vocabulary and\n * deliberately NOT the keys of the unit table filtered by kind. The two\n * differ: Volume's symbols include `c` and `pt` but not `cup`/`cups`, and\n * Time's include `wk` and `mo` but not `week`/`month`. Deriving this list\n * from the unit table instead would roughly quadruple every answer.\n *\n * @returns `[]` if `unit` isn't recognized, rather than throwing.\n */\nexport function getConvertiblePossibilities(unit: string): string[] {\n const resolved = resolveUnit(unit);\n const entry = lookupUnit(resolved);\n if (entry === undefined) return [];\n const symbols = MEASURE_SYMBOLS[entry[0]];\n if (!symbols) return [];\n return symbols.filter((s) => s !== resolved);\n}\n\n/** Check whether `unit` is a unit the conversion tables recognize. Never throws. */\nexport function isConvertibleUnit(unit: string): boolean {\n if (isWorkdayUnit(unit)) return true;\n if (EXTENDED_UNITS[unit]) return true;\n return lookupUnit(resolveUnit(unit)) !== undefined;\n}\n\n/**\n * Convert `value` (in `unit`) to whichever unit of the same measure gives\n * the most human-readable magnitude, e.g. 1500 metres becomes 1.5 km. Falls\n * back to returning `value`/`unit` unchanged if `unit` isn't recognized,\n * which is what every extended unit and workday does.\n *\n * Note the chosen unit is drawn from the best-unit lists, which are not\n * restricted to spellings the lexer accepts: 0.5 l reports \"mL\".\n */\nexport function getBestUnit(value: number, unit: string): { value: number; unit: string } {\n const u = resolveUnit(unit);\n try {\n const result = convertToBestMetric(value, u);\n return { value: result.quantity, unit: result.unit };\n } catch {\n return { value, unit: u };\n }\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunkTY3TLZAW_cjs = require('./chunk-TY3TLZAW.cjs');
|
|
4
|
+
var chunkM4F66R4O_cjs = require('./chunk-M4F66R4O.cjs');
|
|
5
|
+
var chunkOUHT5Z36_cjs = require('./chunk-OUHT5Z36.cjs');
|
|
6
|
+
var chunkCLVQBF5C_cjs = require('./chunk-CLVQBF5C.cjs');
|
|
7
7
|
|
|
8
8
|
// src/lexer/LexerState.ts
|
|
9
9
|
var LexerState = /* @__PURE__ */ ((LexerState2) => {
|
|
@@ -28,7 +28,7 @@ var Lexer = class {
|
|
|
28
28
|
// next()/peek() streaming access.
|
|
29
29
|
this.tokens = [];
|
|
30
30
|
this.tokenIdx = 0;
|
|
31
|
-
this.expressionLexer = new
|
|
31
|
+
this.expressionLexer = new chunkM4F66R4O_cjs.ExpressionLexer(localeCode, tokenLookup);
|
|
32
32
|
}
|
|
33
33
|
reset(input, state) {
|
|
34
34
|
const newState = state ?? "main" /* Main */;
|
|
@@ -145,24 +145,45 @@ var Lexer = class {
|
|
|
145
145
|
}
|
|
146
146
|
return this.collectHighlightTokens(lineText);
|
|
147
147
|
}
|
|
148
|
-
|
|
148
|
+
/**
|
|
149
|
+
* The same tokens {@link getHighlightTokens} reduces, before reduction.
|
|
150
|
+
*
|
|
151
|
+
* Exists because normalization operates on tokens, not on the flattened
|
|
152
|
+
* shape, and a consumer that wants phrase-fused highlighting has to run the
|
|
153
|
+
* normalizer between the two. See `LanguageService.getSemanticTokens`.
|
|
154
|
+
*
|
|
155
|
+
* @param lineText - One line of source.
|
|
156
|
+
* @returns Every token on the line that is worth painting, unreduced.
|
|
157
|
+
*/
|
|
158
|
+
getHighlightTokenObjects(lineText) {
|
|
159
|
+
const classification = this.expressionLexer.classifyLine(lineText);
|
|
160
|
+
if (classification.skip && lineText.startsWith("> ")) {
|
|
161
|
+
return this.collectTokenObjects(lineText.slice(2));
|
|
162
|
+
}
|
|
163
|
+
if (classification.skip) return [];
|
|
164
|
+
return this.collectTokenObjects(lineText);
|
|
165
|
+
}
|
|
166
|
+
collectTokenObjects(lineText) {
|
|
149
167
|
this.resetExpression(lineText);
|
|
150
168
|
const result = [];
|
|
151
169
|
for (const token of this) {
|
|
152
170
|
if (token.type === "WS" || token.type === "NEWLINE") continue;
|
|
153
171
|
if (token.type.startsWith("MD_")) continue;
|
|
154
172
|
if (token.type === "INLINE_SOLVE_START" || token.type === "BACKTICK_CLOSE") continue;
|
|
155
|
-
result.push(
|
|
156
|
-
type: token.type,
|
|
157
|
-
value: token.value,
|
|
158
|
-
offset: token.offset,
|
|
159
|
-
col: token.col,
|
|
160
|
-
length: token.value.length,
|
|
161
|
-
category: chunk6BKTCEUP_cjs.getTokenCategory(token.type)
|
|
162
|
-
});
|
|
173
|
+
result.push(token);
|
|
163
174
|
}
|
|
164
175
|
return result;
|
|
165
176
|
}
|
|
177
|
+
collectHighlightTokens(lineText) {
|
|
178
|
+
return this.collectTokenObjects(lineText).map((token) => ({
|
|
179
|
+
type: token.type,
|
|
180
|
+
value: token.value,
|
|
181
|
+
offset: token.offset,
|
|
182
|
+
col: token.col,
|
|
183
|
+
length: token.value.length,
|
|
184
|
+
category: chunkTY3TLZAW_cjs.getTokenCategory(token.type)
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
166
187
|
};
|
|
167
188
|
var sharedLexer = new Lexer("en", void 0);
|
|
168
189
|
|
|
@@ -298,13 +319,14 @@ var BUILTIN_PHRASES = {
|
|
|
298
319
|
"decrease by": "DECREASE_BY",
|
|
299
320
|
"times by": "TIMES_BY",
|
|
300
321
|
"multiply by": "MULTIPLY_BY",
|
|
322
|
+
"multiplied by": "MULTIPLY_BY",
|
|
301
323
|
"divide by": "DIVIDE_BY"
|
|
302
324
|
};
|
|
303
325
|
function buildTokenLookup(localeCode = "en") {
|
|
304
|
-
const locale =
|
|
326
|
+
const locale = chunkOUHT5Z36_cjs.getLocale(localeCode);
|
|
305
327
|
const registry = new TokenClassRegistry();
|
|
306
328
|
registry.setLocale(locale.keywordMap, BUILTIN_PHRASES);
|
|
307
|
-
registry.setUnits(
|
|
329
|
+
registry.setUnits(chunkCLVQBF5C_cjs.knownUnits);
|
|
308
330
|
return registry.build();
|
|
309
331
|
}
|
|
310
332
|
|
|
@@ -312,5 +334,5 @@ exports.Lexer = Lexer;
|
|
|
312
334
|
exports.LexerState = LexerState;
|
|
313
335
|
exports.buildTokenLookup = buildTokenLookup;
|
|
314
336
|
exports.sharedLexer = sharedLexer;
|
|
315
|
-
//# sourceMappingURL=chunk-
|
|
316
|
-
//# sourceMappingURL=chunk-
|
|
337
|
+
//# sourceMappingURL=chunk-WWOLFXTX.cjs.map
|
|
338
|
+
//# sourceMappingURL=chunk-WWOLFXTX.cjs.map
|