@hyperscale0/hsx 2.4.1 → 3.0.1
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/CHANGELOG.md +4 -406
- package/README.md +3 -92
- package/dist/src/ast.d.ts +99 -310
- package/dist/src/ast.d.ts.map +1 -1
- package/dist/src/ast.js +16 -69
- package/dist/src/ast.js.map +1 -1
- package/dist/src/cli.d.ts +6 -19
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +77 -315
- package/dist/src/cli.js.map +1 -1
- package/dist/src/compile.d.ts +23 -73
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +1113 -148
- package/dist/src/compile.js.map +1 -1
- package/dist/src/cost.d.ts +8 -77
- package/dist/src/cost.d.ts.map +1 -1
- package/dist/src/cost.js +13 -422
- package/dist/src/cost.js.map +1 -1
- package/dist/src/format.d.ts +8 -7
- package/dist/src/format.d.ts.map +1 -1
- package/dist/src/format.js +9 -175
- package/dist/src/format.js.map +1 -1
- package/dist/src/headers.d.ts +35 -0
- package/dist/src/headers.d.ts.map +1 -0
- package/dist/src/headers.js +108 -0
- package/dist/src/headers.js.map +1 -0
- package/dist/src/index.d.ts +6 -12
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -9
- package/dist/src/index.js.map +1 -1
- package/dist/src/lex.d.ts +8 -28
- package/dist/src/lex.d.ts.map +1 -1
- package/dist/src/lex.js +88 -146
- package/dist/src/lex.js.map +1 -1
- package/dist/src/parse.d.ts +4 -17
- package/dist/src/parse.d.ts.map +1 -1
- package/dist/src/parse.js +402 -1040
- package/dist/src/parse.js.map +1 -1
- package/dist/src/std-bundle.d.ts.map +1 -1
- package/dist/src/std-bundle.js +12 -20
- package/dist/src/std-bundle.js.map +1 -1
- package/dist/src/std-library.d.ts +1 -1
- package/dist/src/std-library.d.ts.map +1 -1
- package/dist/src/std-library.js +1 -5
- package/dist/src/std-library.js.map +1 -1
- package/dist/src/tunables.d.ts +7 -0
- package/dist/src/tunables.d.ts.map +1 -0
- package/dist/src/tunables.js +26 -0
- package/dist/src/tunables.js.map +1 -0
- package/dist/src/version.d.ts +2 -4
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +2 -4
- package/dist/src/version.js.map +1 -1
- package/docs/README.md +179 -41
- package/docs/headers.md +44 -0
- package/examples/cost-table.json +99 -751
- package/examples/library.hsx +59 -0
- package/package.json +9 -17
- package/src/ast.ts +82 -441
- package/src/cli.ts +78 -362
- package/src/compile.ts +1535 -247
- package/src/cost.ts +28 -671
- package/src/format.ts +12 -256
- package/src/headers.ts +126 -0
- package/src/index.ts +7 -39
- package/src/lex.ts +99 -195
- package/src/parse.ts +403 -1209
- package/src/std-bundle.ts +12 -20
- package/src/std-library.ts +2 -7
- package/src/tunables.ts +31 -0
- package/src/version.ts +2 -5
- package/std/approvals.hsx +17 -0
- package/std/cards.hsx +63 -0
- package/std/collections.hsx +31 -0
- package/std/escrow.hsx +43 -0
- package/std/financing.hsx +372 -0
- package/std/insurance.hsx +59 -0
- package/std/lending.hsx +115 -0
- package/std/marketplace.hsx +24 -0
- package/std/money.hsx +195 -0
- package/std/savings.hsx +44 -0
- package/std/travel.hsx +98 -0
- package/std/wallet.hsx +41 -0
- package/dist/src/diagnostics.d.ts +0 -13
- package/dist/src/diagnostics.d.ts.map +0 -1
- package/dist/src/diagnostics.js +0 -587
- package/dist/src/diagnostics.js.map +0 -1
- package/dist/src/emit.d.ts +0 -51
- package/dist/src/emit.d.ts.map +0 -1
- package/dist/src/emit.js +0 -192
- package/dist/src/emit.js.map +0 -1
- package/dist/src/entry-overrides.d.ts +0 -58
- package/dist/src/entry-overrides.d.ts.map +0 -1
- package/dist/src/entry-overrides.js +0 -284
- package/dist/src/entry-overrides.js.map +0 -1
- package/dist/src/ir.d.ts +0 -73
- package/dist/src/ir.d.ts.map +0 -1
- package/dist/src/ir.js +0 -15
- package/dist/src/ir.js.map +0 -1
- package/dist/src/limits.d.ts +0 -23
- package/dist/src/limits.d.ts.map +0 -1
- package/dist/src/limits.js +0 -23
- package/dist/src/limits.js.map +0 -1
- package/dist/src/lsp/server.d.ts +0 -32
- package/dist/src/lsp/server.d.ts.map +0 -1
- package/dist/src/lsp/server.js +0 -391
- package/dist/src/lsp/server.js.map +0 -1
- package/dist/src/modules.d.ts +0 -38
- package/dist/src/modules.d.ts.map +0 -1
- package/dist/src/modules.js +0 -372
- package/dist/src/modules.js.map +0 -1
- package/dist/src/typecheck.d.ts +0 -8
- package/dist/src/typecheck.d.ts.map +0 -1
- package/dist/src/typecheck.js +0 -4160
- package/dist/src/typecheck.js.map +0 -1
- package/docs/guide/01-first-program.md +0 -24
- package/docs/guide/02-money.md +0 -25
- package/docs/guide/03-instruments.md +0 -93
- package/docs/guide/04-lifecycles.md +0 -40
- package/docs/guide/05-fees-and-splits.md +0 -45
- package/docs/guide/06-schedules.md +0 -26
- package/docs/guide/07-composition.md +0 -52
- package/docs/guide/08-writing-a-module.md +0 -85
- package/docs/guide/09-cost.md +0 -24
- package/docs/guide/10-diagnostics.md +0 -27
- package/docs/llms-full.txt +0 -3684
- package/docs/llms.txt +0 -44
- package/docs/piece-plans.md +0 -120
- package/docs/playground.md +0 -55
- package/docs/reference/cli.md +0 -36
- package/docs/reference/diagnostics.md +0 -901
- package/docs/reference/grammar.md +0 -38
- package/docs/reference/std/advance.md +0 -112
- package/docs/reference/std/cancellable_booking.md +0 -159
- package/docs/reference/std/captured_payment.md +0 -115
- package/docs/reference/std/conditional_disbursement.md +0 -101
- package/docs/reference/std/credit_facility.md +0 -108
- package/docs/reference/std/held_payment.md +0 -173
- package/docs/reference/std/instant_transfer.md +0 -97
- package/docs/reference/std/metered.md +0 -89
- package/docs/reference/std/pooled_split.md +0 -95
- package/docs/reference/std/premium_forward.md +0 -119
- package/docs/reference/std/reconciled_payout.md +0 -103
- package/docs/reference/std/rotating_pool.md +0 -130
- package/docs/reference/std/scheduled.md +0 -136
- package/docs/reference/std/security_deposit.md +0 -138
- package/docs/reference/std/settlement_batch.md +0 -123
- package/docs/reference/std/swap.md +0 -133
- package/docs/reference/std/threshold_pool.md +0 -138
- package/docs/reference/std/weighted_distribution.md +0 -135
- package/docs/reference/types.md +0 -61
- package/docs/reference/udl-output.md +0 -13
- package/examples/01-first-program/README.md +0 -45
- package/examples/01-first-program/tip-jar.hsx +0 -17
- package/examples/02-imports-and-modules/README.md +0 -96
- package/examples/02-imports-and-modules/photo-booth.hsx +0 -37
- package/examples/03-diagnostics/README.md +0 -68
- package/examples/03-diagnostics/corner-shop-fixed.hsx +0 -22
- package/examples/03-diagnostics/corner-shop.hsx +0 -19
- package/examples/04-complete-product/README.md +0 -84
- package/examples/04-complete-product/study-hall.hsx +0 -67
- package/examples/05-authored-instrument/README.md +0 -5
- package/examples/05-authored-instrument/payment.hsx +0 -37
- package/examples/05-watch-club/README.md +0 -6
- package/examples/05-watch-club/watch-club.hsx +0 -123
- package/examples/README.md +0 -48
- package/examples/advance/README.md +0 -3
- package/examples/advance/advance.hsx +0 -13
- package/examples/advance/advance.udl +0 -367
- package/examples/cancellable_booking/README.md +0 -3
- package/examples/cancellable_booking/cancellable_booking.hsx +0 -14
- package/examples/cancellable_booking/cancellable_booking.udl +0 -413
- package/examples/captured_payment/README.md +0 -3
- package/examples/captured_payment/captured_payment.hsx +0 -17
- package/examples/captured_payment/captured_payment.udl +0 -686
- package/examples/conditional_disbursement/README.md +0 -3
- package/examples/conditional_disbursement/conditional_disbursement.hsx +0 -15
- package/examples/conditional_disbursement/conditional_disbursement.udl +0 -418
- package/examples/credit_facility/README.md +0 -3
- package/examples/credit_facility/credit_facility.hsx +0 -24
- package/examples/credit_facility/credit_facility.udl +0 -1396
- package/examples/held_payment/README.md +0 -3
- package/examples/held_payment/held_payment.hsx +0 -13
- package/examples/held_payment/held_payment.udl +0 -569
- package/examples/instant_transfer/README.md +0 -3
- package/examples/instant_transfer/instant_transfer.hsx +0 -16
- package/examples/instant_transfer/instant_transfer.udl +0 -376
- package/examples/metered/README.md +0 -3
- package/examples/metered/metered.hsx +0 -13
- package/examples/metered/metered.udl +0 -253
- package/examples/pooled_split/README.md +0 -3
- package/examples/pooled_split/pooled_split.hsx +0 -15
- package/examples/pooled_split/pooled_split.udl +0 -432
- package/examples/premium_forward/README.md +0 -3
- package/examples/premium_forward/premium_forward.hsx +0 -19
- package/examples/premium_forward/premium_forward.udl +0 -604
- package/examples/reconciled_payout/README.md +0 -3
- package/examples/reconciled_payout/reconciled_payout.hsx +0 -13
- package/examples/reconciled_payout/reconciled_payout.udl +0 -312
- package/examples/rotating_pool/README.md +0 -3
- package/examples/rotating_pool/rotating_pool.hsx +0 -18
- package/examples/rotating_pool/rotating_pool.udl +0 -4370
- package/examples/scheduled/README.md +0 -3
- package/examples/scheduled/scheduled.hsx +0 -12
- package/examples/scheduled/scheduled.udl +0 -355
- package/examples/security_deposit/README.md +0 -3
- package/examples/security_deposit/security_deposit.hsx +0 -21
- package/examples/security_deposit/security_deposit.udl +0 -320
- package/examples/settlement_batch/README.md +0 -3
- package/examples/settlement_batch/settlement_batch.hsx +0 -19
- package/examples/settlement_batch/settlement_batch.udl +0 -757
- package/examples/swap/README.md +0 -3
- package/examples/swap/swap.hsx +0 -19
- package/examples/swap/swap.udl +0 -892
- package/examples/threshold_pool/README.md +0 -3
- package/examples/threshold_pool/threshold_pool.hsx +0 -16
- package/examples/threshold_pool/threshold_pool.udl +0 -680
- package/examples/weighted_distribution/README.md +0 -3
- package/examples/weighted_distribution/weighted_distribution.hsx +0 -20
- package/examples/weighted_distribution/weighted_distribution.udl +0 -348
- package/skills/hsx/SKILL.md +0 -449
- package/src/diagnostics.ts +0 -620
- package/src/emit.ts +0 -282
- package/src/entry-overrides.ts +0 -428
- package/src/ir.ts +0 -113
- package/src/limits.ts +0 -22
- package/src/lsp/server.ts +0 -460
- package/src/modules.ts +0 -452
- package/src/typecheck.ts +0 -5515
- package/std/SEMANTICS.md +0 -44
- package/std/money_flows/advance.hsx +0 -235
- package/std/money_flows/cancellable_booking.hsx +0 -402
- package/std/money_flows/captured_payment.hsx +0 -220
- package/std/money_flows/conditional_disbursement.hsx +0 -226
- package/std/money_flows/credit_facility.hsx +0 -214
- package/std/money_flows/held_payment.hsx +0 -812
- package/std/money_flows/index.hsx +0 -4
- package/std/money_flows/instant_transfer.hsx +0 -231
- package/std/money_flows/metered.hsx +0 -104
- package/std/money_flows/pooled_split.hsx +0 -109
- package/std/money_flows/premium_forward.hsx +0 -307
- package/std/money_flows/reconciled_payout.hsx +0 -119
- package/std/money_flows/rotating_pool.hsx +0 -305
- package/std/money_flows/scheduled.hsx +0 -599
- package/std/money_flows/security_deposit.hsx +0 -248
- package/std/money_flows/settlement_batch.hsx +0 -173
- package/std/money_flows/swap.hsx +0 -1192
- package/std/money_flows/threshold_pool.hsx +0 -307
- package/std/money_flows/weighted_distribution.hsx +0 -237
package/dist/src/ir.js
DELETED
package/dist/src/ir.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ir.js","sourceRoot":"","sources":["../../src/ir.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,SAAS;IACT,SAAS;IACT,KAAK;IACL,WAAW;IACX,MAAM;IACN,SAAS;IACT,OAAO;IACP,OAAO;IACP,SAAS;IACT,KAAK;IACL,MAAM;IACN,SAAS;CACD,CAAC"}
|
package/dist/src/limits.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What the compiler refuses to read, as opposed to what it refuses to emit.
|
|
3
|
-
* These bounds cap the input side an attacker controls.
|
|
4
|
-
*
|
|
5
|
-
* Both numbers are set against the 34 real programs this compiler is tested
|
|
6
|
-
* on. The deepest nests 5 levels; the largest is 13,934 bytes.
|
|
7
|
-
*/
|
|
8
|
-
export declare const HSX_LIMITS: Readonly<{
|
|
9
|
-
/** Shared ceiling for finite comprehensions and action-call expansion. */
|
|
10
|
-
maxExpansions: 256;
|
|
11
|
-
/**
|
|
12
|
-
* How deep the recursive-descent productions may nest. Measured on this
|
|
13
|
-
* machine, the parser exhausted the call stack at 9,217 nested blocks and
|
|
14
|
-
* threw a RangeError out of `compile`, which SECURITY.md promises never
|
|
15
|
-
* happens. The crash point moves with whatever stack the process has left,
|
|
16
|
-
* so the ceiling is declared here instead of discovered at runtime. 64 is
|
|
17
|
-
* 12x the deepest real program and 144x below that measured crash.
|
|
18
|
-
*/
|
|
19
|
-
maxNestingDepth: 64;
|
|
20
|
-
/** 18x the largest real HSX program. */
|
|
21
|
-
maxSourceBytes: number;
|
|
22
|
-
}>;
|
|
23
|
-
//# sourceMappingURL=limits.d.ts.map
|
package/dist/src/limits.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/limits.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,UAAU;IACrB,0EAA0E;;IAE1E;;;;;;;OAOG;;IAEH,wCAAwC;;EAExC,CAAC"}
|
package/dist/src/limits.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What the compiler refuses to read, as opposed to what it refuses to emit.
|
|
3
|
-
* These bounds cap the input side an attacker controls.
|
|
4
|
-
*
|
|
5
|
-
* Both numbers are set against the 34 real programs this compiler is tested
|
|
6
|
-
* on. The deepest nests 5 levels; the largest is 13,934 bytes.
|
|
7
|
-
*/
|
|
8
|
-
export const HSX_LIMITS = Object.freeze({
|
|
9
|
-
/** Shared ceiling for finite comprehensions and action-call expansion. */
|
|
10
|
-
maxExpansions: 256,
|
|
11
|
-
/**
|
|
12
|
-
* How deep the recursive-descent productions may nest. Measured on this
|
|
13
|
-
* machine, the parser exhausted the call stack at 9,217 nested blocks and
|
|
14
|
-
* threw a RangeError out of `compile`, which SECURITY.md promises never
|
|
15
|
-
* happens. The crash point moves with whatever stack the process has left,
|
|
16
|
-
* so the ceiling is declared here instead of discovered at runtime. 64 is
|
|
17
|
-
* 12x the deepest real program and 144x below that measured crash.
|
|
18
|
-
*/
|
|
19
|
-
maxNestingDepth: 64,
|
|
20
|
-
/** 18x the largest real HSX program. */
|
|
21
|
-
maxSourceBytes: 256 * 1_024,
|
|
22
|
-
});
|
|
23
|
-
//# sourceMappingURL=limits.js.map
|
package/dist/src/limits.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/limits.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;IACtC,0EAA0E;IAC1E,aAAa,EAAE,GAAG;IAClB;;;;;;;OAOG;IACH,eAAe,EAAE,EAAE;IACnB,wCAAwC;IACxC,cAAc,EAAE,GAAG,GAAG,KAAK;CAC5B,CAAC,CAAC"}
|
package/dist/src/lsp/server.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { type LineIndex } from "../ast.ts";
|
|
2
|
-
import type { HsxCompilerHost } from "../modules.ts";
|
|
3
|
-
export interface LspPosition {
|
|
4
|
-
readonly character: number;
|
|
5
|
-
readonly line: number;
|
|
6
|
-
}
|
|
7
|
-
export interface LspRange {
|
|
8
|
-
readonly end: LspPosition;
|
|
9
|
-
readonly start: LspPosition;
|
|
10
|
-
}
|
|
11
|
-
export interface LspDiagnostic {
|
|
12
|
-
readonly code?: string;
|
|
13
|
-
readonly message: string;
|
|
14
|
-
readonly range: LspRange;
|
|
15
|
-
readonly severity: 1 | 2;
|
|
16
|
-
readonly source: "hsx";
|
|
17
|
-
}
|
|
18
|
-
export interface LspServerOptions {
|
|
19
|
-
readonly host?: HsxCompilerHost;
|
|
20
|
-
readonly onExit?: (code: number) => void;
|
|
21
|
-
}
|
|
22
|
-
export interface LspServer {
|
|
23
|
-
readonly stop: () => void;
|
|
24
|
-
}
|
|
25
|
-
export declare function offsetToPosition(index: LineIndex, offset: number): LspPosition;
|
|
26
|
-
export declare function spanToRange(index: LineIndex, span: {
|
|
27
|
-
readonly end: number;
|
|
28
|
-
readonly start: number;
|
|
29
|
-
}): LspRange;
|
|
30
|
-
export declare function createHostForUri(uri: string, fallbackHost?: HsxCompilerHost): HsxCompilerHost;
|
|
31
|
-
export declare function startLspServer(input: NodeJS.ReadableStream, output: NodeJS.WritableStream, options?: LspServerOptions): LspServer;
|
|
32
|
-
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/lsp/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,eAAe,CAAC;AAKnE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,GACb,WAAW,CAcb;AAED,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACrD,QAAQ,CAKV;AAED,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,YAAY,CAAC,EAAE,eAAe,GAC7B,eAAe,CA8CjB;AASD,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,CAAC,cAAc,EAC5B,MAAM,EAAE,MAAM,CAAC,cAAc,EAC7B,OAAO,GAAE,gBAAqB,GAC7B,SAAS,CA2UX"}
|
package/dist/src/lsp/server.js
DELETED
|
@@ -1,391 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
2
|
-
import { dirname, isAbsolute, resolve } from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { lineIndex } from "../ast.js";
|
|
5
|
-
import { format } from "../format.js";
|
|
6
|
-
import { resolveProgramModules } from "../modules.js";
|
|
7
|
-
import { parseProgram } from "../parse.js";
|
|
8
|
-
import { checkGeneralProgram } from "../typecheck.js";
|
|
9
|
-
export function offsetToPosition(index, offset) {
|
|
10
|
-
const clamped = Math.max(0, Math.min(offset, index.length));
|
|
11
|
-
let low = 0;
|
|
12
|
-
let high = index.starts.length - 1;
|
|
13
|
-
while (low < high) {
|
|
14
|
-
const middle = Math.floor((low + high + 1) / 2);
|
|
15
|
-
if (index.starts[middle] <= clamped)
|
|
16
|
-
low = middle;
|
|
17
|
-
else
|
|
18
|
-
high = middle - 1;
|
|
19
|
-
}
|
|
20
|
-
const lineStart = index.starts[low];
|
|
21
|
-
return {
|
|
22
|
-
character: clamped - lineStart,
|
|
23
|
-
line: low,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export function spanToRange(index, span) {
|
|
27
|
-
return {
|
|
28
|
-
end: offsetToPosition(index, Math.max(span.start, span.end)),
|
|
29
|
-
start: offsetToPosition(index, span.start),
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
export function createHostForUri(uri, fallbackHost) {
|
|
33
|
-
let docDir;
|
|
34
|
-
try {
|
|
35
|
-
if (uri.startsWith("file://")) {
|
|
36
|
-
docDir = dirname(fileURLToPath(uri));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
docDir = undefined;
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
resolveModule(specifier, from) {
|
|
44
|
-
if (fallbackHost?.resolveModule) {
|
|
45
|
-
const custom = fallbackHost.resolveModule(specifier, from);
|
|
46
|
-
if (custom)
|
|
47
|
-
return custom;
|
|
48
|
-
}
|
|
49
|
-
if (!docDir)
|
|
50
|
-
return undefined;
|
|
51
|
-
const baseDir = from
|
|
52
|
-
? isAbsolute(from)
|
|
53
|
-
? dirname(from)
|
|
54
|
-
: resolve(docDir, dirname(from))
|
|
55
|
-
: docDir;
|
|
56
|
-
const candidates = [
|
|
57
|
-
resolve(baseDir, specifier),
|
|
58
|
-
resolve(baseDir, `${specifier}.hsx`),
|
|
59
|
-
resolve(docDir, specifier),
|
|
60
|
-
resolve(docDir, `${specifier}.hsx`),
|
|
61
|
-
];
|
|
62
|
-
for (const candidate of candidates) {
|
|
63
|
-
if (existsSync(candidate)) {
|
|
64
|
-
try {
|
|
65
|
-
const stat = statSync(candidate);
|
|
66
|
-
if (stat.isFile()) {
|
|
67
|
-
return {
|
|
68
|
-
name: candidate,
|
|
69
|
-
source: readFileSync(candidate, "utf8"),
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
catch {
|
|
74
|
-
// Ignore filesystem errors and check subsequent candidates.
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return undefined;
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
export function startLspServer(input, output, options = {}) {
|
|
83
|
-
const documents = new Map();
|
|
84
|
-
let isInitialized = false;
|
|
85
|
-
let isShutdown = false;
|
|
86
|
-
let buffer = Buffer.alloc(0);
|
|
87
|
-
const send = (message) => {
|
|
88
|
-
const json = JSON.stringify(message);
|
|
89
|
-
const bytes = Buffer.from(json, "utf8");
|
|
90
|
-
output.write(`Content-Length: ${bytes.length}\r\n\r\n${json}`);
|
|
91
|
-
};
|
|
92
|
-
const validateAndPublish = (uri, source) => {
|
|
93
|
-
const lineIdx = lineIndex(source);
|
|
94
|
-
const diagnostics = [];
|
|
95
|
-
const parsed = parseProgram(source);
|
|
96
|
-
for (const diag of parsed.diagnostics) {
|
|
97
|
-
diagnostics.push({
|
|
98
|
-
...(diag.code ? { code: diag.code } : {}),
|
|
99
|
-
message: diag.message,
|
|
100
|
-
range: spanToRange(lineIdx, diag.span),
|
|
101
|
-
severity: 1,
|
|
102
|
-
source: "hsx",
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
if (parsed.diagnostics.length === 0) {
|
|
106
|
-
const host = createHostForUri(uri, options.host);
|
|
107
|
-
const resolved = resolveProgramModules(parsed.program, host);
|
|
108
|
-
if (!resolved.ok) {
|
|
109
|
-
for (const issue of resolved.issues) {
|
|
110
|
-
diagnostics.push({
|
|
111
|
-
code: issue.code,
|
|
112
|
-
message: issue.message,
|
|
113
|
-
range: spanToRange(lineIdx, issue.span),
|
|
114
|
-
severity: 1,
|
|
115
|
-
source: "hsx",
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
const checked = checkGeneralProgram(resolved.program);
|
|
121
|
-
for (const diag of checked.diagnostics) {
|
|
122
|
-
if (!resolved.origins.has(diag.span)) {
|
|
123
|
-
diagnostics.push({
|
|
124
|
-
code: diag.code,
|
|
125
|
-
message: diag.message,
|
|
126
|
-
range: spanToRange(lineIdx, diag.span),
|
|
127
|
-
severity: diag.severity === "warning" ? 2 : 1,
|
|
128
|
-
source: "hsx",
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
send({
|
|
135
|
-
jsonrpc: "2.0",
|
|
136
|
-
method: "textDocument/publishDiagnostics",
|
|
137
|
-
params: {
|
|
138
|
-
diagnostics,
|
|
139
|
-
uri,
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
};
|
|
143
|
-
const handleMessage = (msg) => {
|
|
144
|
-
const { id, method, params } = msg;
|
|
145
|
-
// Requests (id is present)
|
|
146
|
-
if (id !== undefined) {
|
|
147
|
-
if (isShutdown) {
|
|
148
|
-
send({
|
|
149
|
-
error: {
|
|
150
|
-
code: -32600,
|
|
151
|
-
message: "Invalid request: server is shutting down",
|
|
152
|
-
},
|
|
153
|
-
id,
|
|
154
|
-
jsonrpc: "2.0",
|
|
155
|
-
});
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
if (!isInitialized) {
|
|
159
|
-
if (method !== "initialize") {
|
|
160
|
-
send({
|
|
161
|
-
error: {
|
|
162
|
-
code: -32002,
|
|
163
|
-
message: "Server not initialized",
|
|
164
|
-
},
|
|
165
|
-
id,
|
|
166
|
-
jsonrpc: "2.0",
|
|
167
|
-
});
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
isInitialized = true;
|
|
171
|
-
send({
|
|
172
|
-
id,
|
|
173
|
-
jsonrpc: "2.0",
|
|
174
|
-
result: {
|
|
175
|
-
capabilities: {
|
|
176
|
-
documentFormattingProvider: true,
|
|
177
|
-
textDocumentSync: 1,
|
|
178
|
-
},
|
|
179
|
-
serverInfo: {
|
|
180
|
-
name: "hsx-lsp",
|
|
181
|
-
version: "1.0.0",
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
});
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
if (method === "initialize") {
|
|
188
|
-
send({
|
|
189
|
-
id,
|
|
190
|
-
jsonrpc: "2.0",
|
|
191
|
-
result: {
|
|
192
|
-
capabilities: {
|
|
193
|
-
documentFormattingProvider: true,
|
|
194
|
-
textDocumentSync: 1,
|
|
195
|
-
},
|
|
196
|
-
serverInfo: {
|
|
197
|
-
name: "hsx-lsp",
|
|
198
|
-
version: "1.0.0",
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
});
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
if (method === "shutdown") {
|
|
205
|
-
isShutdown = true;
|
|
206
|
-
send({
|
|
207
|
-
id,
|
|
208
|
-
jsonrpc: "2.0",
|
|
209
|
-
result: null,
|
|
210
|
-
});
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
if (method === "textDocument/formatting") {
|
|
214
|
-
const uri = params?.textDocument?.uri;
|
|
215
|
-
const source = uri ? documents.get(uri) : undefined;
|
|
216
|
-
if (!source) {
|
|
217
|
-
send({ id, jsonrpc: "2.0", result: null });
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
const formatted = format(source);
|
|
221
|
-
if (!formatted.ok) {
|
|
222
|
-
send({ id, jsonrpc: "2.0", result: null });
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
if (formatted.formatted === source) {
|
|
226
|
-
send({ id, jsonrpc: "2.0", result: [] });
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
const lines = lineIndex(source);
|
|
230
|
-
send({
|
|
231
|
-
id,
|
|
232
|
-
jsonrpc: "2.0",
|
|
233
|
-
result: [
|
|
234
|
-
{
|
|
235
|
-
newText: formatted.formatted,
|
|
236
|
-
range: {
|
|
237
|
-
end: offsetToPosition(lines, source.length),
|
|
238
|
-
start: { character: 0, line: 0 },
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
],
|
|
242
|
-
});
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
send({
|
|
246
|
-
error: {
|
|
247
|
-
code: -32601,
|
|
248
|
-
message: `Method not found: ${method ?? "unknown"}`,
|
|
249
|
-
},
|
|
250
|
-
id,
|
|
251
|
-
jsonrpc: "2.0",
|
|
252
|
-
});
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
// Notifications (id is undefined)
|
|
256
|
-
if (method === "exit") {
|
|
257
|
-
const code = isShutdown ? 0 : 1;
|
|
258
|
-
if (options.onExit) {
|
|
259
|
-
options.onExit(code);
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
262
|
-
process.exit(code);
|
|
263
|
-
}
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
if (isShutdown || !isInitialized) {
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
if (method === "initialized") {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
if (method === "textDocument/didOpen") {
|
|
273
|
-
const doc = params?.textDocument;
|
|
274
|
-
if (doc?.uri && typeof doc.text === "string") {
|
|
275
|
-
documents.set(doc.uri, doc.text);
|
|
276
|
-
validateAndPublish(doc.uri, doc.text);
|
|
277
|
-
}
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
if (method === "textDocument/didChange") {
|
|
281
|
-
const uri = params?.textDocument?.uri;
|
|
282
|
-
const changes = params?.contentChanges;
|
|
283
|
-
if (!uri || !Array.isArray(changes) || changes.length === 0) {
|
|
284
|
-
// Empty contentChanges keeps the document and republishes nothing.
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
// Full sync only; an incremental entry would replace the document with a fragment.
|
|
288
|
-
const hasIncremental = changes.some((change) => change && typeof change === "object" && "range" in change);
|
|
289
|
-
if (hasIncremental) {
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
const lastChange = changes[changes.length - 1];
|
|
293
|
-
if (lastChange && typeof lastChange.text === "string") {
|
|
294
|
-
documents.set(uri, lastChange.text);
|
|
295
|
-
validateAndPublish(uri, lastChange.text);
|
|
296
|
-
}
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
if (method === "textDocument/didClose") {
|
|
300
|
-
const uri = params?.textDocument?.uri;
|
|
301
|
-
if (uri) {
|
|
302
|
-
documents.delete(uri);
|
|
303
|
-
send({
|
|
304
|
-
jsonrpc: "2.0",
|
|
305
|
-
method: "textDocument/publishDiagnostics",
|
|
306
|
-
params: {
|
|
307
|
-
diagnostics: [],
|
|
308
|
-
uri,
|
|
309
|
-
},
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
const processBuffer = () => {
|
|
316
|
-
while (true) {
|
|
317
|
-
const headerEnd = buffer.indexOf("\r\n\r\n");
|
|
318
|
-
if (headerEnd === -1)
|
|
319
|
-
break;
|
|
320
|
-
const headerText = buffer.subarray(0, headerEnd).toString("ascii");
|
|
321
|
-
const match = /content-length:\s*(\d+)/i.exec(headerText);
|
|
322
|
-
if (!match) {
|
|
323
|
-
buffer = buffer.subarray(headerEnd + 4);
|
|
324
|
-
continue;
|
|
325
|
-
}
|
|
326
|
-
const contentLength = parseInt(match[1], 10);
|
|
327
|
-
if (Number.isNaN(contentLength) || contentLength < 0) {
|
|
328
|
-
buffer = buffer.subarray(headerEnd + 4);
|
|
329
|
-
continue;
|
|
330
|
-
}
|
|
331
|
-
const totalLength = headerEnd + 4 + contentLength;
|
|
332
|
-
if (buffer.length < totalLength) {
|
|
333
|
-
break;
|
|
334
|
-
}
|
|
335
|
-
const bodyBytes = buffer.subarray(headerEnd + 4, totalLength);
|
|
336
|
-
buffer = buffer.subarray(totalLength);
|
|
337
|
-
const bodyStr = bodyBytes.toString("utf8");
|
|
338
|
-
try {
|
|
339
|
-
const msg = JSON.parse(bodyStr);
|
|
340
|
-
handleMessage(msg);
|
|
341
|
-
}
|
|
342
|
-
catch {
|
|
343
|
-
// Ignore unparseable JSON payload.
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
const flushPending = () => {
|
|
348
|
-
const headerEnd = buffer.indexOf("\r\n\r\n");
|
|
349
|
-
if (headerEnd !== -1) {
|
|
350
|
-
const bodyStr = buffer
|
|
351
|
-
.subarray(headerEnd + 4)
|
|
352
|
-
.toString("utf8")
|
|
353
|
-
.trim();
|
|
354
|
-
if (bodyStr.length > 0) {
|
|
355
|
-
try {
|
|
356
|
-
const msg = JSON.parse(bodyStr);
|
|
357
|
-
handleMessage(msg);
|
|
358
|
-
}
|
|
359
|
-
catch {
|
|
360
|
-
// Ignore unparseable body.
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
const onData = (chunk) => {
|
|
366
|
-
const incoming = typeof chunk === "string" ? Buffer.from(chunk, "utf8") : chunk;
|
|
367
|
-
buffer = Buffer.concat([buffer, incoming]);
|
|
368
|
-
processBuffer();
|
|
369
|
-
};
|
|
370
|
-
const onEnd = () => {
|
|
371
|
-
processBuffer();
|
|
372
|
-
if (buffer.length > 0) {
|
|
373
|
-
flushPending();
|
|
374
|
-
}
|
|
375
|
-
if (options.onExit) {
|
|
376
|
-
options.onExit(0);
|
|
377
|
-
}
|
|
378
|
-
else {
|
|
379
|
-
process.exit(0);
|
|
380
|
-
}
|
|
381
|
-
};
|
|
382
|
-
input.on("data", onData);
|
|
383
|
-
input.on("end", onEnd);
|
|
384
|
-
return {
|
|
385
|
-
stop() {
|
|
386
|
-
input.removeListener("data", onData);
|
|
387
|
-
input.removeListener("end", onEnd);
|
|
388
|
-
},
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
//# sourceMappingURL=server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/lsp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,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AC9C,MAAM,QAAQ,GACZ,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACjE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC3C,aAAa,EAAE,CAAC;IAClB,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,GAAS,EAAE;QACvB,aAAa,EAAE,CAAC;QAChB,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,YAAY,EAAE,CAAC;QACjB,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;IAEF,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzB,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAEvB,OAAO;QACL,IAAI;YACF,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACrC,KAAK,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/src/modules.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { UdlDocument } from "@hyperscale0/udl";
|
|
2
|
-
import type { Program } from "./ast.ts";
|
|
3
|
-
import { type StandardLibrary } from "./std-library.ts";
|
|
4
|
-
export interface ModuleSource {
|
|
5
|
-
readonly name: string;
|
|
6
|
-
readonly source: string;
|
|
7
|
-
}
|
|
8
|
-
export interface HsxCompilerHost {
|
|
9
|
-
readonly moduleName?: string;
|
|
10
|
-
/** Published canonical UDL available to `use` declarations. */
|
|
11
|
-
readonly publishedCatalog?: UdlDocument;
|
|
12
|
-
readonly resolveModule?: (specifier: string, from: string) => ModuleSource | undefined;
|
|
13
|
-
readonly standardLibrary?: StandardLibrary;
|
|
14
|
-
}
|
|
15
|
-
export interface ModuleIssue {
|
|
16
|
-
readonly code: string;
|
|
17
|
-
readonly fix: string;
|
|
18
|
-
readonly message: string;
|
|
19
|
-
readonly span: {
|
|
20
|
-
readonly end: number;
|
|
21
|
-
readonly start: number;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export interface ModuleOrigin {
|
|
25
|
-
readonly column: number;
|
|
26
|
-
readonly line: number;
|
|
27
|
-
readonly moduleName: string;
|
|
28
|
-
}
|
|
29
|
-
export type ModuleResolution = {
|
|
30
|
-
readonly issues: readonly ModuleIssue[];
|
|
31
|
-
readonly ok: false;
|
|
32
|
-
} | {
|
|
33
|
-
readonly ok: true;
|
|
34
|
-
readonly origins: ReadonlyMap<object, ModuleOrigin>;
|
|
35
|
-
readonly program: Program;
|
|
36
|
-
};
|
|
37
|
-
export declare function resolveProgramModules(program: Program, host?: HsxCompilerHost): ModuleResolution;
|
|
38
|
-
//# sourceMappingURL=modules.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../../src/modules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAMV,OAAO,EACR,MAAM,UAAU,CAAC;AAGlB,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEhF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,+DA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