@swiftuijs/twill 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +138 -0
  3. package/bin/twill.mjs +12 -0
  4. package/dist/branches.d.ts +12 -0
  5. package/dist/cli.d.ts +1 -0
  6. package/dist/cli.js +128 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/compiler-Bi9TNOhX.js +1127 -0
  9. package/dist/compiler-Bi9TNOhX.js.map +1 -0
  10. package/dist/compiler.d.ts +50 -0
  11. package/dist/config.d.ts +6 -0
  12. package/dist/config.js +55 -0
  13. package/dist/config.js.map +1 -0
  14. package/dist/declarations.d.ts +14 -0
  15. package/dist/declarations.js +132 -0
  16. package/dist/declarations.js.map +1 -0
  17. package/dist/defer.d.ts +17 -0
  18. package/dist/doctor.d.ts +20 -0
  19. package/dist/doctor.js +198 -0
  20. package/dist/doctor.js.map +1 -0
  21. package/dist/editor.d.ts +53 -0
  22. package/dist/editor.js +261 -0
  23. package/dist/editor.js.map +1 -0
  24. package/dist/esbuild.d.ts +3 -0
  25. package/dist/esbuild.js +7 -0
  26. package/dist/esbuild.js.map +1 -0
  27. package/dist/files-D1mERoxc.js +46 -0
  28. package/dist/files-D1mERoxc.js.map +1 -0
  29. package/dist/files.d.ts +5 -0
  30. package/dist/index.d.ts +2 -0
  31. package/dist/index.js +2 -0
  32. package/dist/loader.d.ts +3 -0
  33. package/dist/loader.js +54 -0
  34. package/dist/loader.js.map +1 -0
  35. package/dist/parser.d.ts +9 -0
  36. package/dist/plugin-BGabvyT6.js +112 -0
  37. package/dist/plugin-BGabvyT6.js.map +1 -0
  38. package/dist/plugin.d.ts +9 -0
  39. package/dist/project.d.ts +62 -0
  40. package/dist/project.js +416 -0
  41. package/dist/project.js.map +1 -0
  42. package/dist/recovery.d.ts +3 -0
  43. package/dist/register.d.ts +1 -0
  44. package/dist/register.js +7 -0
  45. package/dist/register.js.map +1 -0
  46. package/dist/rollup.d.ts +3 -0
  47. package/dist/rollup.js +7 -0
  48. package/dist/rollup.js.map +1 -0
  49. package/dist/rspack.d.ts +3 -0
  50. package/dist/rspack.js +7 -0
  51. package/dist/rspack.js.map +1 -0
  52. package/dist/syntax.d.ts +11 -0
  53. package/dist/syntax.js +10 -0
  54. package/dist/syntax.js.map +1 -0
  55. package/dist/transpile-DwVekVFM.js +51 -0
  56. package/dist/transpile-DwVekVFM.js.map +1 -0
  57. package/dist/transpile.d.ts +11 -0
  58. package/dist/typescript-plugin.LICENSE.txt +375 -0
  59. package/dist/typescript-plugin.cjs +17741 -0
  60. package/dist/typescript-plugin.cjs.map +1 -0
  61. package/dist/typescript-plugin.d.ts +5 -0
  62. package/dist/vite-react.d.ts +10 -0
  63. package/dist/vite-react.js +22 -0
  64. package/dist/vite-react.js.map +1 -0
  65. package/dist/vite.d.ts +3 -0
  66. package/dist/vite.js +7 -0
  67. package/dist/vite.js.map +1 -0
  68. package/dist/webpack.d.ts +3 -0
  69. package/dist/webpack.js +7 -0
  70. package/dist/webpack.js.map +1 -0
  71. package/package.json +180 -0
  72. package/schemas/twill.schema.json +16 -0
@@ -0,0 +1,5 @@
1
+ import { default as ts } from 'typescript/lib/tsserverlibrary';
2
+ /** Semantic bridge for native TS/JS documents in configured mixed projects. */
3
+ export default function init(_modules: {
4
+ typescript: typeof ts;
5
+ }): ts.server.PluginModule;
@@ -0,0 +1,10 @@
1
+ import { Options as ReactOptions } from '@vitejs/plugin-react';
2
+ import { PluginOption } from 'vite';
3
+ import { PluginOptions } from './vite.js';
4
+ export interface TwillReactOptions {
5
+ twill?: PluginOptions;
6
+ react?: ReactOptions;
7
+ }
8
+ /** Compose the normal Vite React plugin with dialect compilation and refresh
9
+ * filtering. Component libraries keep ordinary React APIs and JSX semantics. */
10
+ export default function twillReact(options?: TwillReactOptions): PluginOption[];
@@ -0,0 +1,22 @@
1
+ import vite_default from "./vite.js";
2
+ import react from "@vitejs/plugin-react";
3
+ //#region src/vite-react.ts
4
+ /** Compose the normal Vite React plugin with dialect compilation and refresh
5
+ * filtering. Component libraries keep ordinary React APIs and JSX semantics. */
6
+ function twillReact(options = {}) {
7
+ if (options.react?.jsxRuntime === "classic") throw new Error("Twill React uses the automatic JSX runtime.");
8
+ const jsxImportSource = options.react?.jsxImportSource ?? options.twill?.jsxImportSource;
9
+ const runtime = jsxImportSource === void 0 ? {} : { jsxImportSource };
10
+ return [vite_default({
11
+ ...options.twill,
12
+ ...runtime
13
+ }), react({
14
+ include: /\.(?:[cm]?[jt]sx?|twillx?)(?:\?.*)?$/,
15
+ ...options.react,
16
+ ...runtime
17
+ })];
18
+ }
19
+ //#endregion
20
+ export { twillReact as default };
21
+
22
+ //# sourceMappingURL=vite-react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-react.js","names":["twill"],"sources":["../src/vite-react.ts"],"sourcesContent":["import react, { type Options as ReactOptions } from '@vitejs/plugin-react';\nimport type { PluginOption } from 'vite';\nimport twill, { type PluginOptions } from './vite.js';\n\nexport interface TwillReactOptions {\n twill?: PluginOptions;\n react?: ReactOptions;\n}\n\n/** Compose the normal Vite React plugin with dialect compilation and refresh\n * filtering. Component libraries keep ordinary React APIs and JSX semantics. */\nexport default function twillReact(options: TwillReactOptions = {}): PluginOption[] {\n if (options.react?.jsxRuntime === 'classic')\n throw new Error('Twill React uses the automatic JSX runtime.');\n const jsxImportSource = options.react?.jsxImportSource ?? options.twill?.jsxImportSource;\n // An absent override must leave standard tsconfig inheritance intact.\n const runtime = jsxImportSource === undefined ? {} : { jsxImportSource };\n return [\n twill({ ...options.twill, ...runtime }),\n react({\n include: /\\.(?:[cm]?[jt]sx?|twillx?)(?:\\?.*)?$/,\n ...options.react,\n ...runtime,\n }),\n ];\n}\n"],"mappings":";;;;;AAWA,SAAwB,WAAW,UAA6B,CAAC,GAAmB;CAClF,IAAI,QAAQ,OAAO,eAAe,WAChC,MAAM,IAAI,MAAM,6CAA6C;CAC/D,MAAM,kBAAkB,QAAQ,OAAO,mBAAmB,QAAQ,OAAO;CAEzE,MAAM,UAAU,oBAAoB,KAAA,IAAY,CAAC,IAAI,EAAE,gBAAgB;CACvE,OAAO,CACLA,aAAM;EAAE,GAAG,QAAQ;EAAO,GAAG;CAAQ,CAAC,GACtC,MAAM;EACJ,SAAS;EACT,GAAG,QAAQ;EACX,GAAG;CACL,CAAC,CACH;AACF"}
package/dist/vite.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ declare const _default: (options?: import('./plugin.js').PluginOptions | undefined) => import('vite').Plugin<any>;
2
+ export default _default;
3
+ export type { PluginOptions } from './plugin.js';
package/dist/vite.js ADDED
@@ -0,0 +1,7 @@
1
+ import { t as twillPlugin } from "./plugin-BGabvyT6.js";
2
+ //#region src/vite.ts
3
+ var vite_default = twillPlugin.vite;
4
+ //#endregion
5
+ export { vite_default as default };
6
+
7
+ //# sourceMappingURL=vite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["import { twillPlugin } from './plugin.js';\nexport default twillPlugin.vite;\nexport type { PluginOptions } from './plugin.js';\n"],"mappings":";;AACA,IAAA,eAAe,YAAY"}
@@ -0,0 +1,3 @@
1
+ declare const _default: (options?: import('./plugin.js').PluginOptions | undefined) => import('unplugin').WebpackPluginInstance;
2
+ export default _default;
3
+ export type { PluginOptions } from './plugin.js';
@@ -0,0 +1,7 @@
1
+ import { t as twillPlugin } from "./plugin-BGabvyT6.js";
2
+ //#region src/webpack.ts
3
+ var webpack_default = twillPlugin.webpack;
4
+ //#endregion
5
+ export { webpack_default as default };
6
+
7
+ //# sourceMappingURL=webpack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpack.js","names":[],"sources":["../src/webpack.ts"],"sourcesContent":["import { twillPlugin } from './plugin.js';\nexport default twillPlugin.webpack;\nexport type { PluginOptions } from './plugin.js';\n"],"mappings":";;AACA,IAAA,kBAAe,YAAY"}
package/package.json ADDED
@@ -0,0 +1,180 @@
1
+ {
2
+ "name": "@swiftuijs/twill",
3
+ "version": "0.1.0",
4
+ "description": "Twill: a JS/TS syntax-sugar language with trailing closures, guards, block-scoped defer, build plugins, type checking, and editor support.",
5
+ "main": "./dist/typescript-plugin.cjs",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/swiftuijs/twill.git",
9
+ "directory": "packages/twill"
10
+ },
11
+ "keywords": [
12
+ "javascript",
13
+ "typescript",
14
+ "trailing-closures",
15
+ "swift",
16
+ "vite",
17
+ "unplugin",
18
+ "react",
19
+ "vue",
20
+ "twill",
21
+ "guard",
22
+ "defer"
23
+ ],
24
+ "author": {
25
+ "name": "forth.ink",
26
+ "url": "https://forth.ink"
27
+ },
28
+ "license": "MIT",
29
+ "type": "module",
30
+ "bugs": {
31
+ "url": "https://github.com/swiftuijs/twill/issues"
32
+ },
33
+ "homepage": "https://swiftuijs.github.io/twill/",
34
+ "dependencies": {
35
+ "@ampproject/remapping": "^2.3.0",
36
+ "@jridgewell/trace-mapping": "^0.3.31",
37
+ "acorn": "8.18.0",
38
+ "acorn-jsx": "^5.3.2",
39
+ "acorn-typescript": "1.4.13",
40
+ "magic-string": "^1.4.2",
41
+ "typescript": "5.9.3",
42
+ "unplugin": "^3.4.0"
43
+ },
44
+ "sideEffects": false,
45
+ "engines": {
46
+ "node": "^20.19.0 || >=22.12.0"
47
+ },
48
+ "files": [
49
+ "bin",
50
+ "dist/**/*.js",
51
+ "dist/**/*.js.map",
52
+ "dist/**/*.d.ts",
53
+ "schemas",
54
+ "README.md",
55
+ "LICENSE",
56
+ "dist/**/*.cjs",
57
+ "dist/**/*.cjs.map",
58
+ "dist/*.LICENSE.txt"
59
+ ],
60
+ "bin": {
61
+ "twill": "./bin/twill.mjs"
62
+ },
63
+ "exports": {
64
+ ".": {
65
+ "types": "./dist/index.d.ts",
66
+ "import": "./dist/index.js"
67
+ },
68
+ "./vite": {
69
+ "types": "./dist/vite.d.ts",
70
+ "import": "./dist/vite.js"
71
+ },
72
+ "./rollup": {
73
+ "types": "./dist/rollup.d.ts",
74
+ "import": "./dist/rollup.js"
75
+ },
76
+ "./esbuild": {
77
+ "types": "./dist/esbuild.d.ts",
78
+ "import": "./dist/esbuild.js"
79
+ },
80
+ "./webpack": {
81
+ "types": "./dist/webpack.d.ts",
82
+ "import": "./dist/webpack.js"
83
+ },
84
+ "./rspack": {
85
+ "types": "./dist/rspack.d.ts",
86
+ "import": "./dist/rspack.js"
87
+ },
88
+ "./project": {
89
+ "types": "./dist/project.d.ts",
90
+ "import": "./dist/project.js"
91
+ },
92
+ "./editor": {
93
+ "types": "./dist/editor.d.ts",
94
+ "import": "./dist/editor.js"
95
+ },
96
+ "./register": {
97
+ "types": "./dist/register.d.ts",
98
+ "import": "./dist/register.js"
99
+ },
100
+ "./schema": "./schemas/twill.schema.json",
101
+ "./typescript-plugin": {
102
+ "types": "./dist/typescript-plugin.d.ts",
103
+ "require": "./dist/typescript-plugin.cjs",
104
+ "default": "./dist/typescript-plugin.cjs"
105
+ },
106
+ "./doctor": {
107
+ "types": "./dist/doctor.d.ts",
108
+ "import": "./dist/doctor.js"
109
+ },
110
+ "./syntax": {
111
+ "types": "./dist/syntax.d.ts",
112
+ "import": "./dist/syntax.js"
113
+ },
114
+ "./config": {
115
+ "types": "./dist/config.d.ts",
116
+ "import": "./dist/config.js"
117
+ },
118
+ "./declarations": {
119
+ "types": "./dist/declarations.d.ts",
120
+ "import": "./dist/declarations.js"
121
+ },
122
+ "./vite-react": {
123
+ "types": "./dist/vite-react.d.ts",
124
+ "import": "./dist/vite-react.js"
125
+ }
126
+ },
127
+ "peerDependencies": {
128
+ "react": "^18.2.0 || ^19.0.0",
129
+ "vue": "^3.3.0",
130
+ "@vitejs/plugin-react": "^6.1.1"
131
+ },
132
+ "peerDependenciesMeta": {
133
+ "react": {
134
+ "optional": true
135
+ },
136
+ "vue": {
137
+ "optional": true
138
+ },
139
+ "@vitejs/plugin-react": {
140
+ "optional": true
141
+ }
142
+ },
143
+ "types": "./dist/index.d.ts",
144
+ "publishConfig": {
145
+ "access": "public"
146
+ },
147
+ "module": "./dist/index.js",
148
+ "devDependencies": {
149
+ "vite": "^8.3.2",
150
+ "vite-plugin-dts": "^5.1.2",
151
+ "@types/node": "^26.6.4",
152
+ "@vitejs/plugin-react": "^6.1.1",
153
+ "vitest": "^5.0.3",
154
+ "@vitest/coverage-v8": "^5.0.3",
155
+ "@rspack/core": "^2.2.8",
156
+ "@types/react": "^19.3.0",
157
+ "@types/react-dom": "^19.3.0",
158
+ "@vue/server-renderer": "^3.5.43",
159
+ "esbuild": "^0.28.2",
160
+ "react": "^19.3.0",
161
+ "react-dom": "^19.3.0",
162
+ "rollup": "^4.64.0",
163
+ "vue": "^3.5.43",
164
+ "webpack": "^5.111.1",
165
+ "@playwright/test": "^1.63.0"
166
+ },
167
+ "scripts": {
168
+ "build": "vite build && vite build --config vite.plugin.config.ts && node scripts/prepare-core.mjs",
169
+ "typecheck": "tsc --noEmit -p tsconfig.json",
170
+ "test:unit": "vitest run",
171
+ "test:watch": "vitest",
172
+ "test:coverage": "vitest run --coverage",
173
+ "test:package": "node tests/consumer.mjs",
174
+ "test:size": "node tests/bundle-size.mjs",
175
+ "test:browser": "playwright test",
176
+ "benchmark": "node benchmarks/compiler.mjs",
177
+ "test": "pnpm run test:unit",
178
+ "benchmark:branching": "node benchmarks/branching.mjs"
179
+ }
180
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft-07/schema#",
3
+ "title": "Twill configuration",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "properties": {
7
+ "$schema": {
8
+ "type": "string"
9
+ },
10
+ "implicitReturn": {
11
+ "type": "boolean",
12
+ "default": true,
13
+ "description": "Return the value of a single-expression ordinary closure."
14
+ }
15
+ }
16
+ }