@backtickjs/core 0.1.2 → 0.1.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/ClientScript.d.ts +1 -0
- package/dist/ClientScript.js.map +1 -1
- package/dist/cs.d.ts +2 -0
- package/dist/cs.js +7 -0
- package/dist/cs.js.map +1 -1
- package/package.json +1 -1
- package/src/ClientScript.ts +3 -0
- package/src/cs.ts +10 -0
package/dist/ClientScript.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface ClientModule {
|
|
|
12
12
|
readonly map: string;
|
|
13
13
|
readonly dependencies: readonly string[];
|
|
14
14
|
readonly params: readonly Param[];
|
|
15
|
+
readonly kind: "function" | "expression" | "block";
|
|
15
16
|
}
|
|
16
17
|
export interface ClientScript {
|
|
17
18
|
readonly "@backtickjs": "ClientScript";
|
package/dist/ClientScript.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientScript.js","sourceRoot":"","sources":["../src/ClientScript.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ClientScript.js","sourceRoot":"","sources":["../src/ClientScript.ts"],"names":[],"mappings":"AAsCA,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,aAAa,IAAI,KAAK;QACtB,KAAK,CAAC,aAAa,CAAC,KAAK,cAAc,CACxC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,MAAM,CACpB,MAAoB,EACpB,IAA2B;IAE3B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AACzD,CAAC"}
|
package/dist/cs.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { Spliceable } from "./Spliceable.js";
|
|
|
4
4
|
import type { Spliced } from "./Spliceable.js";
|
|
5
5
|
declare function lift<T>(_: T): Client<T>;
|
|
6
6
|
declare function splice<T extends [T] extends [Spliceable] ? unknown : Spliceable>(_: T): unknown extends Spliced<T> ? any : Spliced<T>;
|
|
7
|
+
declare function awaited<T>(_: T): Awaited<T>;
|
|
7
8
|
/**
|
|
8
9
|
* The globals a project declares — its libs, `@types`, a `declare global` —
|
|
9
10
|
* as an ordinary object type: reading one it doesn't declare is an error
|
|
@@ -14,6 +15,7 @@ export type GlobalThis = {
|
|
|
14
15
|
[Key in keyof typeof globalThis]: (typeof globalThis)[Key];
|
|
15
16
|
};
|
|
16
17
|
export declare const cs: ((_strings: TemplateStringsArray, ..._values: unknown[]) => Client<unknown>) & {
|
|
18
|
+
awaited: typeof awaited;
|
|
17
19
|
create: typeof create;
|
|
18
20
|
lift: typeof lift;
|
|
19
21
|
splice: typeof splice;
|
package/dist/cs.js
CHANGED
|
@@ -13,8 +13,15 @@ function splice(_) {
|
|
|
13
13
|
throw new Error("Don't call `cs.splice` directly; it's used to generate virtual " +
|
|
14
14
|
"code for the typechecker. Write code using cs`...` instead.");
|
|
15
15
|
}
|
|
16
|
+
// `await`, in a splice the host may await in: what the host's `await` gives,
|
|
17
|
+
// wherever in the script the splice is written.
|
|
18
|
+
function awaited(_) {
|
|
19
|
+
throw new Error("Don't call `cs.awaited` directly; it's used to generate virtual " +
|
|
20
|
+
"code for the typechecker. Write code using cs`...` instead.");
|
|
21
|
+
}
|
|
16
22
|
// What hangs off the tag.
|
|
17
23
|
const members = {
|
|
24
|
+
awaited,
|
|
18
25
|
create,
|
|
19
26
|
lift,
|
|
20
27
|
splice,
|
package/dist/cs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cs.js","sourceRoot":"","sources":["../src/cs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAI3C,uBAAuB;AACvB,SAAS,IAAI,CAAI,CAAI;IACnB,MAAM,IAAI,KAAK,CACb,+DAA+D;QAC7D,6DAA6D,CAChE,CAAC;AACJ,CAA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C7B,CAAC,QAA8B,EAAE,GAAG,OAAkB,EAAmB,EAAE;IACzE,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;AACJ,CAAC,EACD,OAEC,CACF,CAAC"}
|
package/package.json
CHANGED
package/src/ClientScript.ts
CHANGED
|
@@ -23,6 +23,9 @@ export interface ClientModule {
|
|
|
23
23
|
readonly dependencies: readonly string[];
|
|
24
24
|
// `params[i]` is the function's `$splice<i>` or `$capture<i>`
|
|
25
25
|
readonly params: readonly Param[];
|
|
26
|
+
// What the script is written as: a function, `(props) => …`, which a splice
|
|
27
|
+
// reads as that function; or an expression or a block, which a splice runs.
|
|
28
|
+
readonly kind: "function" | "expression" | "block";
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
// One run of a `cs`: its module, and the values that run passes it.
|
package/src/cs.ts
CHANGED
|
@@ -25,8 +25,18 @@ function splice<T extends [T] extends [Spliceable] ? unknown : Spliceable>(
|
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
// `await`, in a splice the host may await in: what the host's `await` gives,
|
|
29
|
+
// wherever in the script the splice is written.
|
|
30
|
+
function awaited<T>(_: T): Awaited<T> {
|
|
31
|
+
throw new Error(
|
|
32
|
+
"Don't call `cs.awaited` directly; it's used to generate virtual " +
|
|
33
|
+
"code for the typechecker. Write code using cs`...` instead.",
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
28
37
|
// What hangs off the tag.
|
|
29
38
|
const members = {
|
|
39
|
+
awaited,
|
|
30
40
|
create,
|
|
31
41
|
lift,
|
|
32
42
|
splice,
|