@tsrx/vue 0.1.70 → 0.2.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.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Vue compiler built on @tsrx/core",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.1.70",
6
+ "version": "0.2.0",
7
7
  "type": "module",
8
8
  "publishConfig": {
9
9
  "access": "public"
@@ -38,8 +38,8 @@
38
38
  "esrap": "^2.3.2",
39
39
  "is-reference": "^3.0.3",
40
40
  "zimmerframe": "^1.1.2",
41
- "@tsrx/core": "0.1.70",
42
- "@tsrx/vue-runtime": "0.1.7"
41
+ "@tsrx/core": "0.2.0",
42
+ "@tsrx/vue-runtime": "0.1.8"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "vue": ">=3.5",
package/src/index.js CHANGED
@@ -2,7 +2,15 @@
2
2
  /** @import { BaseCompileOptions, CompileError, CompileResult, ParseOptions, VolarMappingsResult } from '@tsrx/core/types' */
3
3
  /** @import { NonEmptyString } from '@tsrx/core/types/helpers' */
4
4
 
5
- import { analyzeTsrx, createVolarMappingsResult, dedupeMappings, parseModule } from '@tsrx/core';
5
+ import {
6
+ analyzeTsrx,
7
+ createVolarMappingsResult,
8
+ dedupeMappings,
9
+ hasPlatformNamespace,
10
+ parseModule,
11
+ specializePlatform,
12
+ withPlatformTypes,
13
+ } from '@tsrx/core';
6
14
  import { transform } from './transform.js';
7
15
 
8
16
  export { isRefProp } from './ref.js';
@@ -33,11 +41,17 @@ export function compile(source, filename, options) {
33
41
  const errors = /** @type {CompileError[]} */ ([]);
34
42
  const comments = /** @type {AST.CommentWithLocation[]} */ ([]);
35
43
  const collect = !!(options?.collect || options?.loose);
36
- const ast = parseModule(
44
+ let ast = parseModule(
37
45
  source,
38
46
  filename,
39
47
  collect ? { collect: true, loose: !!options?.loose, errors, comments } : undefined,
40
48
  );
49
+ ast = specializePlatform(
50
+ ast,
51
+ options?.platform,
52
+ filename,
53
+ collect ? { errors, comments } : undefined,
54
+ );
41
55
  analyzeTsrx(
42
56
  ast,
43
57
  filename,
@@ -64,7 +78,7 @@ export function compile(source, filename, options) {
64
78
  export function compile_to_volar_mappings(source, filename, options) {
65
79
  const errors = /** @type {CompileError[]} */ ([]);
66
80
  const comments = /** @type {AST.CommentWithLocation[]} */ ([]);
67
- const ast = parseModule(source, filename, {
81
+ let ast = parseModule(source, filename, {
68
82
  ...options,
69
83
  collect: true,
70
84
  loose: !!options?.loose,
@@ -73,6 +87,8 @@ export function compile_to_volar_mappings(source, filename, options) {
73
87
  errors,
74
88
  comments,
75
89
  });
90
+ const uses_platform_flags = hasPlatformNamespace(ast);
91
+ ast = specializePlatform(ast, options?.platform, filename, { errors, comments });
76
92
  analyzeTsrx(ast, filename, {
77
93
  collect: true,
78
94
  loose: !!options?.loose,
@@ -98,8 +114,9 @@ export function compile_to_volar_mappings(source, filename, options) {
98
114
  errors,
99
115
  });
100
116
 
101
- return {
117
+ const deduped = {
102
118
  ...result,
103
119
  mappings: dedupeMappings(result.mappings),
104
120
  };
121
+ return uses_platform_flags ? withPlatformTypes(deduped, options?.platform) : deduped;
105
122
  }
package/types/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { Program } from 'estree';
2
2
  import type { BaseCompileOptions, CompileFn, ParseOptions, VolarCompileFn } from '@tsrx/core/types';
3
3
 
4
- export type { RuntimeImportMode } from '@tsrx/core/types';
4
+ export type { Platform, RuntimeImportMode, TsrxPlatformFlags } from '@tsrx/core/types';
5
5
 
6
6
  export function parse(source: string, filename?: string, options?: ParseOptions): Program;
7
7