create-octane-xplat 0.7.2 → 0.9.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/README.md +10 -5
- package/index.mjs +9 -1
- package/package.json +8 -8
- package/template/.agents/skills/xplat/SKILL.md +2 -2
- package/template/.agents/skills/xplat/references/platform.md +6 -2
- package/template/AGENTS.md +1 -1
- package/template/package.json +11 -9
- package/template/pnpm-workspace.yaml +54 -32
- package/template/src/App.tsrx +12 -3
- package/template/src/process.d.ts +7 -0
- package/template/tsconfig.json +1 -1
- package/template/vite.config.ts +5 -3
- package/template/App_Resources/iOS/src/OctaneShaders.metal +0 -128
- package/template/App_Resources/iOS/src/ShaderEffectRegistration.swift +0 -31
- package/template/patches/@nativescript-community__octane@0.2.1.patch +0 -16
- package/template/patches/@nativescript-community__vite-octane@0.2.1.patch +0 -41
- package/template/patches/@nativescript__core@9.1.2.patch +0 -752
- package/template/patches/@nativescript__core@9.1.3-next.2.patch +0 -428
- package/template/patches/@nativescript__vite@8.0.11.patch +0 -564
- package/template/patches/@nativescript__vite@8.0.13.patch +0 -233
- package/template/patches/@tsrx__typescript-plugin@0.4.11.patch +0 -11
- package/template/patches/css@3.0.0.patch +0 -52
- package/template/patches/octane@0.6.3.patch +0 -1149
- /package/template/src/{index.ts → main.ts} +0 -0
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
diff --git a/helpers/ts-config-paths.js b/helpers/ts-config-paths.js
|
|
2
|
-
index 27013b5c8f78a72b6e6df903ac36f72fc0d75c1a..53a2e7d489ab91593cbec47ee6fb640fc56c786f 100644
|
|
3
|
-
--- a/helpers/ts-config-paths.js
|
|
4
|
-
+++ b/helpers/ts-config-paths.js
|
|
5
|
-
@@ -113,15 +113,20 @@ function resolveTsConfigPath(fullPath, platform, verbose, debugId) {
|
|
6
|
-
if (verbose && debugId) {
|
|
7
|
-
console.log(`📁 TypeScript path candidate: ${debugId} -> ${fullPath}`);
|
|
8
|
-
}
|
|
9
|
-
+ // `.mobile` is the shared ios/android suffix tier — it sits between the os
|
|
10
|
-
+ // qualifier and the unsuffixed default. Probing it per extension keeps
|
|
11
|
-
+ // paths-mapped imports consistent with the bundler's extension chain.
|
|
12
|
-
+ const suffixes = platform === 'ios' || platform === 'android' ? [platform, 'mobile'] : platform ? [platform] : [];
|
|
13
|
-
if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) {
|
|
14
|
-
- const platformIndexPatterns = [`index.${platform}.ts`, `index.${platform}.js`, `index.${platform}.mjs`];
|
|
15
|
-
- for (const indexFile of platformIndexPatterns) {
|
|
16
|
-
- const indexPath = path.join(fullPath, indexFile);
|
|
17
|
-
- if (fs.existsSync(indexPath)) {
|
|
18
|
-
- if (verbose) {
|
|
19
|
-
- console.log(`📁 Found platform-specific directory index: ${indexPath}`);
|
|
20
|
-
+ for (const suffix of suffixes) {
|
|
21
|
-
+ for (const ext of ['.ts', '.js', '.mjs']) {
|
|
22
|
-
+ const indexPath = path.join(fullPath, `index.${suffix}${ext}`);
|
|
23
|
-
+ if (fs.existsSync(indexPath)) {
|
|
24
|
-
+ if (verbose) {
|
|
25
|
-
+ console.log(`📁 Found platform-specific directory index: ${indexPath}`);
|
|
26
|
-
+ }
|
|
27
|
-
+ return indexPath;
|
|
28
|
-
}
|
|
29
|
-
- return indexPath;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
for (const indexFile of ['index.ts', 'index.js', 'index.mjs']) {
|
|
33
|
-
@@ -135,12 +140,14 @@ function resolveTsConfigPath(fullPath, platform, verbose, debugId) {
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
for (const ext of ['.ts', '.js', '.mjs']) {
|
|
37
|
-
- const platformPath = `${fullPath}.${platform}${ext}`;
|
|
38
|
-
- if (fs.existsSync(platformPath)) {
|
|
39
|
-
- if (verbose) {
|
|
40
|
-
- console.log(`📁 Found platform-specific file: ${platformPath}`);
|
|
41
|
-
+ for (const suffix of suffixes) {
|
|
42
|
-
+ const platformPath = `${fullPath}.${suffix}${ext}`;
|
|
43
|
-
+ if (fs.existsSync(platformPath)) {
|
|
44
|
-
+ if (verbose) {
|
|
45
|
-
+ console.log(`📁 Found platform-specific file: ${platformPath}`);
|
|
46
|
-
+ }
|
|
47
|
-
+ return platformPath;
|
|
48
|
-
}
|
|
49
|
-
- return platformPath;
|
|
50
|
-
}
|
|
51
|
-
const basePath = `${fullPath}${ext}`;
|
|
52
|
-
if (fs.existsSync(basePath)) {
|
|
53
|
-
diff --git a/hmr/server/device-transform-helpers.js b/hmr/server/device-transform-helpers.js
|
|
54
|
-
index f0dcb8390b45e42db1abf0023e748422093c2e8e..4897d28a48c0f5b11ee26dc492fc98f93d12eaf1 100644
|
|
55
|
-
--- a/hmr/server/device-transform-helpers.js
|
|
56
|
-
+++ b/hmr/server/device-transform-helpers.js
|
|
57
|
-
@@ -89,7 +89,11 @@ function bareSpecifierFromFlatDepPath(depPath) {
|
|
58
|
-
return bareSpecifier;
|
|
59
|
-
}
|
|
60
|
-
function rewriteVitePrebundleImportsForDevice(code, preserveVendorImports) {
|
|
61
|
-
- const imports = collectTopLevelImportRecords(code);
|
|
62
|
-
+ // Re-export statements (`export { x } from`/`export * from`) carry specifiers
|
|
63
|
-
+ // too — vite's importAnalysis rewrites them to `.vite/deps?v=` URLs the same
|
|
64
|
-
+ // as `import` declarations, so they need the same decode. Barrel modules
|
|
65
|
-
+ // (e.g. a linked framework package's index) are nothing but re-exports.
|
|
66
|
-
+ const imports = collectTopLevelImportRecords(code, true);
|
|
67
|
-
if (!imports.length) {
|
|
68
|
-
return code;
|
|
69
|
-
}
|
|
70
|
-
diff --git a/hmr/server/rewrite-imports.js b/hmr/server/rewrite-imports.js
|
|
71
|
-
index 8a73227ead0209fe7f7d921c120a57f356e72a31..566fed5f14e2c8e971cb388f8a5579cb40079eea 100644
|
|
72
|
-
--- a/hmr/server/rewrite-imports.js
|
|
73
|
-
+++ b/hmr/server/rewrite-imports.js
|
|
74
|
-
@@ -254,11 +254,29 @@ export function rewriteImports(code, importerPath, sfcFileMap, depFileMap, proje
|
|
75
|
-
}
|
|
76
|
-
return `${prefix}${rewritten}${suffix}`;
|
|
77
|
-
}
|
|
78
|
-
- // Path resolves outside both roots — leave Vite's URL alone as a
|
|
79
|
-
- // last resort. The original behaviour was to fall through here
|
|
80
|
-
- // and let downstream branches (e.g. `normalizeNodeModulesSpecifier`)
|
|
81
|
-
- // handle paths whose abs form happens to contain `/node_modules/`,
|
|
82
|
-
- // so preserve that for the unrewritable case below.
|
|
83
|
-
+ // Path resolves outside both roots — the `link:`/`workspace:` case,
|
|
84
|
-
+ // where a package's realpath lives in another checkout entirely.
|
|
85
|
-
+ // A raw /@fs URL makes the device fetch vite's standard middleware
|
|
86
|
-
+ // response, bypassing the device transform: optimizer
|
|
87
|
-
+ // `.vite/deps?v=` specifiers inside reach the runtime unrewritten
|
|
88
|
-
+ // and 504 once the optimizer re-commits its browserHash. The /ns/m
|
|
89
|
-
+ // route already resolves an absolute `/@fs` spec through the full
|
|
90
|
-
+ // device pipeline, so route it there. Paths whose realpath still
|
|
91
|
-
+ // contains /node_modules/ keep falling through to the bare-package
|
|
92
|
-
+ // branch below (upstream behavior).
|
|
93
|
-
+ if (!spec.includes('/node_modules/')) {
|
|
94
|
-
+ const out = `/ns/m${spec}`;
|
|
95
|
-
+ if (httpOriginSafe) {
|
|
96
|
-
+ return `${prefix}${httpOriginSafe}${out}${suffix}`;
|
|
97
|
-
+ }
|
|
98
|
-
+ return `${prefix}${out}${suffix}`;
|
|
99
|
-
+ }
|
|
100
|
-
+ // Path resolves outside both roots but still names a node_modules
|
|
101
|
-
+ // file — leave Vite's URL alone as a last resort. The original
|
|
102
|
-
+ // behaviour was to fall through here and let downstream branches
|
|
103
|
-
+ // (e.g. `normalizeNodeModulesSpecifier`) handle paths whose abs
|
|
104
|
-
+ // form happens to contain `/node_modules/`, so preserve that for
|
|
105
|
-
+ // the unrewritable case below.
|
|
106
|
-
}
|
|
107
|
-
// Vite 8 oxc runtime helpers (decorators etc.) — emitted as
|
|
108
|
-
// `/@id/__x00__@oxc-project+runtime@<ver>/helpers/<name>.js`. These are
|
|
109
|
-
diff --git a/hmr/server/websocket-module-bindings.js b/hmr/server/websocket-module-bindings.js
|
|
110
|
-
index 7f5a692c12255fd84e220989ec312a2b2c6ae4aa..aefc8e01df9f5794e483ac30026c004f318fe1ec 100644
|
|
111
|
-
--- a/hmr/server/websocket-module-bindings.js
|
|
112
|
-
+++ b/hmr/server/websocket-module-bindings.js
|
|
113
|
-
@@ -7,6 +7,7 @@ import { getProjectRootPath } from '../../helpers/project.js';
|
|
114
|
-
import { extractRootPackageName } from '../shared/package-classifier.js';
|
|
115
|
-
import { isEsmFrameworkPackageSpecifier, isLikelyNativeScriptPluginSpecifier, isLikelyNativeScriptRuntimePluginSpecifier, normalizeNodeModulesSpecifier, resolveInternalRuntimePluginBareSpecifier, resolveNodeModulesPackageBoundary, resolveVendorFromCandidate, shouldPreserveBareRuntimePluginSubpathImport } from './websocket-module-specifiers.js';
|
|
116
|
-
import { MODULE_IMPORT_ANALYSIS_PLUGINS } from './websocket-served-module-helpers.js';
|
|
117
|
-
+import { getVendorManifest, resolveVendorSpecifier } from '../shared/vendor/registry.js';
|
|
118
|
-
import { stripViteFsPrefix } from '../../helpers/normalize-id.js';
|
|
119
|
-
const sourceImportIntentCache = new Map();
|
|
120
|
-
const EXPLICIT_RUNTIME_PLUGIN_SCRIPT_EXT_RE = /(?:\.(?:ios|android|visionos|windows))?\.(?:ts|tsx|js|jsx|mjs|mts|cts)$/i;
|
|
121
|
-
@@ -110,6 +111,9 @@ export function ensureNativeScriptModuleBindings(code, options) {
|
|
122
|
-
}
|
|
123
|
-
const runtimePluginBareSpecifier = resolveInternalRuntimePluginBareSpecifier(specifier, getProjectRootPath());
|
|
124
|
-
let canonical = runtimePluginBareSpecifier || resolveVendorFromCandidate(specifier);
|
|
125
|
-
+ if (canonical && getVendorManifest() && !resolveVendorSpecifier(canonical)) {
|
|
126
|
-
+ canonical = null;
|
|
127
|
-
+ }
|
|
128
|
-
const runtimePluginSpecifier = isLikelyNativeScriptRuntimePluginSpecifier(canonical || specifier, getProjectRootPath());
|
|
129
|
-
// Preserving a bare vendor id is only correct where the IMPORT MAP
|
|
130
|
-
// exists to route it (main realm). Worker realms have no import map —
|
|
131
|
-
@@ -121,7 +125,7 @@ export function ensureNativeScriptModuleBindings(code, options) {
|
|
132
|
-
preservedImports.push(original);
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
- if (!canonical && isLikelyNativeScriptPluginSpecifier(specifier, getProjectRootPath())) {
|
|
136
|
-
+ if (!canonical && isLikelyNativeScriptPluginSpecifier(specifier, getProjectRootPath()) && (!getVendorManifest() || resolveVendorSpecifier(specifier))) {
|
|
137
|
-
canonical = specifier;
|
|
138
|
-
}
|
|
139
|
-
if (canonical && /^@nativescript\/core(\b|\/)/i.test(canonical)) {
|
|
140
|
-
@@ -164,6 +168,9 @@ export function ensureNativeScriptModuleBindings(code, options) {
|
|
141
|
-
}
|
|
142
|
-
const runtimePluginBareSpecifier = resolveInternalRuntimePluginBareSpecifier(specifier, getProjectRootPath());
|
|
143
|
-
let canonical = runtimePluginBareSpecifier || resolveVendorFromCandidate(specifier);
|
|
144
|
-
+ if (canonical && getVendorManifest() && !resolveVendorSpecifier(canonical)) {
|
|
145
|
-
+ canonical = null;
|
|
146
|
-
+ }
|
|
147
|
-
const runtimePluginSpecifier = isLikelyNativeScriptRuntimePluginSpecifier(canonical || specifier, getProjectRootPath());
|
|
148
|
-
// See the side-effect branch above: bare preservation relies on the main
|
|
149
|
-
// realm's import map; in a worker serve (vendorImportsAsHttp) it must not
|
|
150
|
-
@@ -172,7 +179,7 @@ export function ensureNativeScriptModuleBindings(code, options) {
|
|
151
|
-
preservedImports.push(original);
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
- if (!canonical && isLikelyNativeScriptPluginSpecifier(specifier, getProjectRootPath())) {
|
|
155
|
-
+ if (!canonical && isLikelyNativeScriptPluginSpecifier(specifier, getProjectRootPath()) && (!getVendorManifest() || resolveVendorSpecifier(specifier))) {
|
|
156
|
-
canonical = specifier;
|
|
157
|
-
}
|
|
158
|
-
if (canonical && /^@nativescript\/core(\b|\/)/i.test(canonical)) {
|
|
159
|
-
diff --git a/hmr/server/websocket-module-specifiers.js b/hmr/server/websocket-module-specifiers.js
|
|
160
|
-
index fbbf61aa12ecff2820f4fe2906314c63583e47a4..9aa92b30d0324ce5886d4cb0dd8b3f321b0cccc3 100644
|
|
161
|
-
--- a/hmr/server/websocket-module-specifiers.js
|
|
162
|
-
+++ b/hmr/server/websocket-module-specifiers.js
|
|
163
|
-
@@ -793,16 +793,24 @@ export function resolveVendorRouting(nodeModulesSpec, projectRoot) {
|
|
164
|
-
if (rootPackageName && pkgName !== rootPackageName) {
|
|
165
|
-
return { route: 'http' };
|
|
166
|
-
}
|
|
167
|
-
- if (isLikelyNativeScriptRuntimePluginSpecifier(pkgName, projectRoot) && (!subpath || isRootLevelMainEntry)) {
|
|
168
|
-
+ // A plugin-patterned package absent from an active vendor manifest (a
|
|
169
|
-
+ // transitive dep under pnpm's isolated linker, an NS_VENDOR_EXCLUDE/
|
|
170
|
-
+ // flavor-excluded package) must not take the vendor route — the registry
|
|
171
|
-
+ // has no entry and the sync require resolves to the missing-module stub.
|
|
172
|
-
+ // Fall through to null so callers emit the per-module /ns/m HTTP form,
|
|
173
|
-
+ // which resolves transitive deps through Vite's importer-aware resolution.
|
|
174
|
-
+ // A null manifest (early boot) keeps the legacy behavior.
|
|
175
|
-
+ const manifest = getVendorManifest();
|
|
176
|
-
+ const pluginVendored = !manifest || !!manifest.modules?.[pkgName];
|
|
177
|
-
+ if (isLikelyNativeScriptRuntimePluginSpecifier(pkgName, projectRoot) && pluginVendored && (!subpath || isRootLevelMainEntry)) {
|
|
178
|
-
return { route: 'vendor', bareSpec: pkgName };
|
|
179
|
-
}
|
|
180
|
-
- if (isLikelyNativeScriptRuntimePluginSpecifier(pkgName, projectRoot) && subpath.includes('/')) {
|
|
181
|
-
+ if (isLikelyNativeScriptRuntimePluginSpecifier(pkgName, projectRoot) && pluginVendored && subpath.includes('/')) {
|
|
182
|
-
const exactBareSpecifier = resolveInternalRuntimePluginBareSpecifier(nodeModulesSpec, projectRoot);
|
|
183
|
-
if (exactBareSpecifier) {
|
|
184
|
-
return { route: 'vendor', bareSpec: exactBareSpecifier };
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
- const manifest = getVendorManifest();
|
|
188
|
-
if (!manifest?.modules?.[pkgName]) {
|
|
189
|
-
return null;
|
|
190
|
-
}
|
|
191
|
-
diff --git a/hmr/server/websocket-ns-m-request.js b/hmr/server/websocket-ns-m-request.js
|
|
192
|
-
index b54aefcc839e95906d76d02e522c052a706ca76f..f743ffd852e2915acbbd42a0f7d80964e86718a4 100644
|
|
193
|
-
--- a/hmr/server/websocket-ns-m-request.js
|
|
194
|
-
+++ b/hmr/server/websocket-ns-m-request.js
|
|
195
|
-
@@ -49,6 +49,14 @@ export function createNsMRequestContext(requestUrl, serverRoot, appVirtualWithSl
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
spec = spec.replace(/[?#].*$/, '');
|
|
199
|
-
+ // urlObj.pathname keeps percent-encoding — device fetches encode
|
|
200
|
-
+ // characters like `[`/`]` in file-based route names, so decode the
|
|
201
|
-
+ // spec before resolving it to a filesystem path. Malformed escapes
|
|
202
|
-
+ // keep the raw spelling rather than throwing.
|
|
203
|
-
+ try {
|
|
204
|
-
+ spec = decodeURIComponent(spec);
|
|
205
|
-
+ }
|
|
206
|
-
+ catch { }
|
|
207
|
-
const decorated = collapseLegacyNsMTags(spec, 'inbound-request-spec');
|
|
208
|
-
spec = decorated.cleanedSpec;
|
|
209
|
-
bootTaggedRequest = decorated.bootTaggedRequest;
|
|
210
|
-
diff --git a/hmr/server/websocket-served-module-helpers.js b/hmr/server/websocket-served-module-helpers.js
|
|
211
|
-
index e65b1abaaf223cca4b11b65b8428c85c484f125d..4cbf72b0aebf54f362634a10e051c48c219f6c8b 100644
|
|
212
|
-
--- a/hmr/server/websocket-served-module-helpers.js
|
|
213
|
-
+++ b/hmr/server/websocket-served-module-helpers.js
|
|
214
|
-
@@ -105,8 +105,8 @@ export function classifyServedRequest(spec, resolvedId) {
|
|
215
|
-
return classifyServedModule(spec);
|
|
216
|
-
}
|
|
217
|
-
export const MODULE_IMPORT_ANALYSIS_PLUGINS = ['typescript', 'jsx', 'importMeta', 'topLevelAwait', 'classProperties', 'classPrivateProperties', 'classPrivateMethods', 'decorators-legacy'];
|
|
218
|
-
-export function collectTopLevelImportRecords(code) {
|
|
219
|
-
- if (!code || typeof code !== 'string' || !/\bimport\b/.test(code)) {
|
|
220
|
-
+export function collectTopLevelImportRecords(code, includeReExports = false) {
|
|
221
|
-
+ if (!code || typeof code !== 'string' || !(includeReExports ? /\b(?:import|export)\b/ : /\bimport\b/).test(code)) {
|
|
222
|
-
return [];
|
|
223
|
-
}
|
|
224
|
-
try {
|
|
225
|
-
@@ -119,7 +119,7 @@ export function collectTopLevelImportRecords(code) {
|
|
226
|
-
return [];
|
|
227
|
-
}
|
|
228
|
-
return body
|
|
229
|
-
- .filter((node) => t.isImportDeclaration(node) && typeof node.start === 'number' && typeof node.end === 'number' && typeof node.source?.value === 'string')
|
|
230
|
-
+ .filter((node) => (t.isImportDeclaration(node) || (includeReExports && (t.isExportNamedDeclaration(node) || t.isExportAllDeclaration(node)))) && typeof node.start === 'number' && typeof node.end === 'number' && typeof node.source?.value === 'string')
|
|
231
|
-
.map((node) => ({
|
|
232
|
-
start: node.start,
|
|
233
|
-
end: node.end,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
diff --git a/dist/language-CofXAudP.js b/dist/language-CofXAudP.js
|
|
2
|
-
index 0d5504342813cd32b77bc834f9ed01bf6a353e3f..aff65966aba619c96f627474bb8e36c34d44f3e1 100644
|
|
3
|
-
--- a/dist/language-CofXAudP.js
|
|
4
|
-
+++ b/dist/language-CofXAudP.js
|
|
5
|
-
@@ -3,5 +3,5 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
|
|
6
|
-
`));return e?null:void 0}let u=D(o.layers,e=>ne(e.config));if(u.state===`invalid`)return j(`Invalid TSRX ${u.target} declaration:`,u.actual_type,u.actual_value,`in ${u.config_path}`),null;let f=o.extends_failures.filter(e=>u.state!==`declared`||!B(o.layers,e,u.config_path));if(f.length>0){for(let e of f){if(e.diagnostics.length===0){j(`Unable to resolve tsconfig extends entry:`,JSON.stringify(e.extends_value),`in ${e.config_path}`);continue}for(let t of e.diagnostics)j(`Unable to resolve tsconfig extends entry:`,JSON.stringify(e.extends_value),`in ${e.config_path}`,n.flattenDiagnosticMessageText(t.messageText,`
|
|
7
|
-
`))}return null}if(u.state===`declared`)return ae(n,r,u.config_path,u.value)}function se(e,t={}){let n=t.ts??l.default,r=t.configHost??n.sys,i=I(r),a=t.configFileName??R(d.default.dirname(e),r,i);if(a===null)return;let o=z(n,r,a,i);for(let e of o.dependencies)t.dependencies?.add(e);let s=o.layers.find(e=>e.raw_source===void 0);if(s){let e=`Unable to read tsconfig layer while resolving TSRX platform: ${s.path}`;throw j(e),Error(e)}let c=o.layers.filter(e=>e.parse_diagnostics.length>0);if(c.length>0){if(!o.layers.some(e=>E(e.config,[`tsrx`]).state===`found`?!0:e.parse_diagnostics.length>0&&e.raw_source!==void 0&&M.test(e.raw_source)))return;let e=c[0],t=n.flattenDiagnosticMessageText(e.parse_diagnostics[0].messageText,`
|
|
8
|
-
`),r=`Unable to parse tsconfig layer while resolving TSRX platform: ${e.path}: ${t}`;throw j(r),Error(r)}let u=D(o.layers,e=>re(e.config));if(u.state===`invalid`){let e=u.target===`platform`?` Expected "web", "ios", or "android".`:``,t=`Invalid TSRX ${u.target} declaration: ${u.actual_type} ${u.actual_value} in ${u.config_path}.${e}`;throw j(t),TypeError(t)}let f=o.extends_failures.filter(e=>u.state!==`declared`||!B(o.layers,e,u.config_path));if(f.length>0){if(!t.requirePlatformResolution)return u.state===`declared`?u.value:void 0;let e=f[0],r=e.diagnostics.length>0?`: ${n.flattenDiagnosticMessageText(e.diagnostics[0].messageText,`
|
|
9
|
-
-`)}`:``,i=`Unable to resolve tsconfig extends entry ${JSON.stringify(e.extends_value)} in ${e.config_path} while resolving TSRX platform${r}`;throw j(i),Error(i)}return u.state===`declared`?u.value:void 0}const ce=(0,f.createRequire)(require(`url`).pathToFileURL(__filename).href),le=d.default.dirname((0,p.fileURLToPath)(require(`url`).pathToFileURL(__filename).href)),{log:V,logWarning:H,logError:U}=k(`[TSRX Language]`),W=new Set,G=[`.tsrx`],K=[[`@tsrx/ripple`,[`node_modules`,`@tsrx`,`ripple`],[`.tsrx`],[`@tsrx/ripple`,`ripple`,`@ripple-ts/vite-plugin`]],[`@tsrx/react`,[`node_modules`,`@tsrx`,`react`],[`.tsrx`],[`@tsrx/react`,`@tsrx/vite-plugin-react`]],[`@tsrx/solid`,[`node_modules`,`@tsrx`,`solid`],[`.tsrx`],[`@tsrx/solid`,`@tsrx/vite-plugin-solid`]],[`@tsrx/preact`,[`node_modules`,`@tsrx`,`preact`],[`.tsrx`],[`@tsrx/preact`,`@tsrx/vite-plugin-preact`]],[`@tsrx/vue`,[`node_modules`,`@tsrx`,`vue`],[`.tsrx`],[`@tsrx/vue`,`@tsrx/vite-plugin-vue`]],[`@tsrx/hono`,[`node_modules`,`@tsrx`,`hono`],[`.tsrx`],[`@tsrx/hono`,`@tsrx/vite-plugin-hono`]],[`octane`,[`node_modules`,`octane`],[`.tsrx`],[`octane`,`@octanejs/vite-plugin`],[[`dist`,`compiler`,`volar.js`],[`src`,`compiler`,`volar.js`]]]],ue=[[`src`,`index.js`]];function de(e){return G.some(t=>e.endsWith(t))}function fe(e,t=l.default){let n=t.createScanner(t.ScriptTarget.Latest,!0,t.LanguageVariant.JSX,e),r=[];for(let e=n.scan();e!==t.SyntaxKind.EndOfFileToken;e=n.scan())r.push({kind:e,text:n.getTokenText()});let i=[`import`,`.`,`meta`,`.`,`env`,`.`,`platform`,`.`];for(let e=0;e+i.length<r.length;e+=1){if(e>0&&(r[e-1].kind===t.SyntaxKind.DotToken||r[e-1].kind===t.SyntaxKind.QuestionDotToken)||!i.every((t,n)=>r[e+n].text===t))continue;let n=r[e+i.length].text;if(n===`web`||n===`ios`||n===`android`)return!0}return!1}function pe(e={}){V(`Creating TSRX language plugin...`);let t=e.ts??l.default,n={...e,ts:t,configHost:e.configHost??t.sys};return{getLanguageId(e){let t=typeof e==`string`?e:e.fsPath.replace(/\\/g,`/`);if(de(t))return V(`Identified TSRX file:`,t),`tsrx`},createVirtualCode(e,t,r){if(t===`tsrx`){let t=ve(e),i=ye(t,n);if(!i){U(`TSRX compiler not found for file: ${t}`);return}V(`Creating virtual code for:`,t);try{return new q(t,r,i,e=>se(t,{...n,requirePlatformResolution:e}))}catch(e){throw U(`Failed to create virtual code for:`,t,`:`,e),e}}},updateVirtualCode(e,t,n){if(t instanceof q)return V(`Updating existing virtual code for:`,t.fileName),t.update(n),t},typescript:{extraFileExtensions:G.map(e=>({extension:e.slice(1),isMixedContent:!1,scriptKind:7})),getServiceScript(e){for(let t of(0,w.forEachEmbeddedCode)(e))if(t.languageId===`tsrx`)return{code:t,extension:`.tsx`,scriptKind:4}},...process.env.TSRX_TSC===`true`?null:{getExtraServiceScripts(e,t){let n=[];for(let r of(0,w.forEachEmbeddedCode)(t))r.languageId===`typescript`&&n.push({fileName:`${e}.${r.id}.ts`,code:r,extension:`.ts`,scriptKind:l.default.ScriptKind.TS});return n}}}}}var q=class{id=`root`;languageId=`tsrx`;codegenStacks=[];tsrx;platformProvider;generatedCode=``;embeddedCodes=[];mappings=[];fatalErrors=[];usageErrors=[];snapshot;sourceSnapshot;originalCode=``;sourceAst=null;isDotCompletionMode=!1;diagnostics=[];#e=null;#t=null;constructor(e,t,n,r){if(V(`Initializing TSRXVirtualCode for:`,e),this.fileName=e,this.tsrx=n,this.platformProvider=r,this.snapshot=t,this.sourceSnapshot=t,this.originalCode=t.getText(0,t.getLength()),!n||typeof n.compile_to_volar_mappings!=`function`)throw U(`Invalid TSRX compiler - missing compile_to_volar_mappings method`),Error(`Invalid TSRX compiler`);this.update(t)}update(e){V(`Updating virtual code for:`,this.fileName);let t=e.getText(0,e.getLength()),n=e.getChangeRange(this.sourceSnapshot);this.sourceSnapshot=e,this.#e=null,this.#t=null,this.fatalErrors=[],this.usageErrors=[],this.sourceAst=null,this.isDotCompletionMode=!1;let r,i=!1,a=-1;if(V(`changeRange:`,JSON.stringify(n)),n){let e=n.span.start,r=e+n.span.length,o=e+n.newLength,s=this.originalCode.substring(e,r),c=t.substring(e,o);if(V(`Change details:`),V(` Position:`,e,`-`,r,`(length:`,n.span.length,`)`),V(` Old text:`,JSON.stringify(s)),V(` New text:`,JSON.stringify(c),`(length:`,n.newLength,`)`),c.endsWith(`.`)){let e=o>1?t[o-2]:``;V(` Char before dot:`,JSON.stringify(e)),/[$#_\u200C\u200D\p{ID_Continue}\)\]\}]/u.test(e)&&(i=!0,a=o-1,V(`ChangeRange detected dot typed at position`,a))}}try{let e=this.platformProvider?.(fe(t));if(i&&a>=0){this.isDotCompletionMode=!0;let n=t.substring(0,a)+t.substring(a+1);if(V(`Compiling without typed dot at position`,a),r=this.tsrx.compile_to_volar_mappings(n,this.fileName,{loose:!0,platform:e}),V(`Compilation without dot successful`),r&&r.code&&r.mappings.length>0){let e=ge(r,a);e===null?H(`Failed to restore typed dot into transpiled output`):V(`Inserted typed dot at generated position`,e)}}else V(`Compiling TSRX code...`),r=this.tsrx.compile_to_volar_mappings(t,this.fileName,{loose:!0,platform:e}),V(`Compilation successful, generated code length:`,r?.code?.length||0)}catch(e){let t=e;U(`TSRX compilation failed for`,this.fileName,`:`,t),process.env.TSRX_TSC===`true`&&Y(this.fileName,[t]),t.type=`fatal`,this.fatalErrors.push(t)}if(r&&r.code){this.originalCode=t,this.generatedCode=r.code,this.mappings=r.mappings??[],this.usageErrors=r.errors,this.sourceAst=r.sourceAst,process.env.TSRX_TSC===`true`&&r.errors.length>0&&Y(this.fileName,r.errors);let e=r.cssMappings,n=r.scriptMappings??[];if(e.length>0||n.length>0){V(`Creating`,e.length,`CSS and`,n.length,`script embedded codes`);let t=[];for(let n of e)t.push(X(n,`css`));for(let e of n)t.push(X(e,`typescript`));this.embeddedCodes=t}else this.embeddedCodes=[];if(O){V(`CSS embedded codes:`,(this.embeddedCodes||[]).length),V(`Using transpiled code, mapping count:`,this.mappings.length),V(`Original code length:`,t.length),V(`Generated code length:`,this.generatedCode.length),V(`Last 100 chars of original:`,JSON.stringify(t.slice(-100))),V(`Last 200 chars of generated:`,JSON.stringify(this.generatedCode.slice(-200))),V(`Last few mappings:`);let e=Math.max(0,this.mappings.length-5);for(let t=e;t<this.mappings.length;t++){let e=this.mappings[t];V(` Mapping ${t}: source[${e.sourceOffsets[0]}:${e.sourceOffsets[0]+e.lengths[0]}] -> gen[${e.generatedOffsets[0]}:${e.generatedOffsets[0]+e.lengths[0]}], len=${e.lengths[0]}, completion=${e.data?.completion}`)}}this.snapshot={getText:(e,t)=>this.generatedCode.substring(e,t),getLength:()=>this.generatedCode.length,getChangeRange:()=>void 0}}else V(`Compilation failed, only display where the compilation error occurred.`),this.originalCode=t,this.generatedCode=t,this.mappings=[{sourceOffsets:[0],generatedOffsets:[0],lengths:[t.length],generatedLengths:[t.length],data:{completion:!0,verification:!0,customData:{}}}],this.embeddedCodes=[...me(t),...he(t)],this.snapshot={getText:(e,t)=>this.generatedCode.substring(e,t),getLength:()=>this.generatedCode.length,getChangeRange:()=>void 0}}#n(){if(!(this.#e||this.#t)){this.#e=new Map,this.#t=new Map;for(var e,t,n,r,i,a,o,s,c,l=0;l<this.mappings.length;l++)e=this.mappings[l],t=e.generatedOffsets[0],n=e.generatedLengths[0],r=t+n,i=`${t}-${r}`,this.#e.set(i,e),a=e.sourceOffsets[0],o=e.lengths[0],s=a+o,c=`${a}-${s}`,this.#t.set(c,e)}}findMappingByGeneratedRange(e,t){return this.#n(),this.#e.get(`${e}-${t}`)??null}findMappingBySourceRange(e,t){return this.#n(),this.#t.get(`${e}-${t}`)??null}findGeneratedRangeBySourceRange(e,t){let n=null,r=null;for(let i=0;i<this.mappings.length;i++){let a=this.mappings[i],o=a.sourceOffsets[0],s=o+a.lengths[0];s<=e||o>=t||((!n||o<n.sourceOffsets[0])&&(n=a),(!r||s>r.sourceOffsets[0]+r.lengths[0])&&(r=a))}if(!n||!r)return null;let i=n.generatedOffsets[0]+J(e-n.sourceOffsets[0],n.generatedLengths[0]),a=r.generatedOffsets[0]+J(t-r.sourceOffsets[0],r.generatedLengths[0]);return[i,Math.max(a,i+1)]}};function J(e,t){return Math.min(Math.max(e,0),t)}function Y(e,t){for(let n of t){let t=n&&typeof n==`object`&&`message`in n?String(n.message):String(n),r=`${e}\0${t}`;W.has(r)||(W.add(r),console.error(`[tsrx-tsc] ${e}: ${t}`))}}function me(e){let t=[],n=/<style\b((?:[^>"'{}/]|"[^"]*"|'[^']*'|\{(?:[^{}]|\{[^{}]*\})*\}|\/(?!>))*)>([\s\S]*?)<\/style>/gi,r,i=0;for(;(r=n.exec(e))!==null;){let e=r[1],n=r[2],a=r.index+(6+e.length+1),o=n.length,s=`style_${i}`;V(`Extracted CSS region ${i}: offset ${a}, length ${o}`);let c={sourceOffsets:[a],generatedOffsets:[0],lengths:[o],generatedLengths:[o],data:{verification:!0,completion:!0,semantic:!0,navigation:!0,structure:!0,format:!1,customData:{content:n,embeddedId:s}}};t.push(X(c,`css`)),i++}return t.length>0&&V(`Extracted ${t.length} CSS embedded codes from style tags`),t}function X(e,t){let n=e.data?.customData?.content??``;return{id:e.data?.customData?.embeddedId,languageId:t,snapshot:{getText:(e,t)=>n.substring(e,t),getLength:()=>e.lengths[0],getChangeRange:()=>void 0},mappings:[e],embeddedCodes:[]}}function he(e){let t=[],n=/<script\b((?:[^>"'/]|"[^"]*"|'[^']*'|\/(?!>))*)>([\s\S]*?)<\/script>/gi,r,i=0;for(;(r=n.exec(e))!==null;){let e=r[1],n=r[2],a=r.index+(7+e.length+1),o=n.length,s=`script_${i}`;V(`Extracted script region ${i}: offset ${a}, length ${o}`);let c={sourceOffsets:[a],generatedOffsets:[0],lengths:[o],generatedLengths:[o],data:{verification:!0,completion:!0,semantic:!0,navigation:!0,structure:!0,format:!1,customData:{content:n,embeddedId:s}}};t.push(X(c,`typescript`)),i++}return t.length>0&&V(`Extracted ${t.length} script embedded codes from script tags`),t}function ge(e,t){let n=null;for(let r of e.mappings)if(r.sourceOffsets[0]+r.lengths[0]===t){n=r;break}if(!n)return null;let r=n.generatedLengths[0],i=n.generatedOffsets[0]+r;e.code=e.code.substring(0,i)+`.`+e.code.substring(i);let a={sourceOffsets:[t],generatedOffsets:[i],lengths:[1],generatedLengths:[1],data:{...n.data}},o=e.mappings.indexOf(n);e.mappings.splice(o+1,0,a);for(let r of e.mappings)r!==n&&r!==a&&r.generatedOffsets[0]>=i&&(r.generatedOffsets[0]+=1),r!==n&&r!==a&&r.sourceOffsets[0]>=t&&(r.sourceOffsets[0]+=1);return i}const _e=new Map,Z=new Map;function ve(e){return typeof e==`string`?e:e.fsPath.replace(/\\/g,`/`)}function Q(e,t=u.default.existsSync){let n=e,r=[];for(;n;){if(Z.has(n)){let e=Z.get(n)??null;for(let t of r)Z.set(t,e);return e}r.push(n);let e=d.default.join(n,`package.json`);if(t(e))try{let t=JSON.parse(u.default.readFileSync(e,`utf8`)),n=new Set([...Object.keys(t.dependencies??{}),...Object.keys(t.devDependencies??{}),...Object.keys(t.peerDependencies??{}),...Object.keys(t.optionalDependencies??{})]),i={name:typeof t.name==`string`?t.name:null,dependencies:n};for(let e of r)Z.set(e,i);return i}catch{for(let e of r)Z.set(e,null);return null}let i=d.default.dirname(n);if(i===n)break;n=i}for(let e of r)Z.set(e,null);return null}function $(e,t,n){if(!e)return!1;if(e.name===t||n.includes(e.name??``)||e.dependencies.has(t))return!0;for(let t of n)if(e.dependencies.has(t))return!0;return!1}function ye(e,t){let n=Se(e,t);if(n)return be(ce(n))}function be(e){return typeof e?.compile_to_volar_mappings!=`function`&&typeof e?.compileToVolarMappings==`function`?{...e,compile_to_volar_mappings:e.compileToVolarMappings}:e}function xe(e,t=u.default.existsSync,n=_e){let r=e.split(`/`),i=d.default.extname(e);for(let e=r.length-2;e>=0;e--){let a=r.slice(0,e+1).join(`/`),o=a+`\0`+i;if(!n.has(o)){let e=[];for(let[n,r,o,s,c=ue]of K)if(o.includes(i))for(let i of c){let o=[a,...r,...i].join(`/`);if(t(o)){e.push([n,o,s]);break}}let r=null;if(e.length>0){let n=Q(a,t);r=e.find(([e,,t])=>$(n,e,t))?.[1]??e[0][1],V(`Found tsrx compiler at:`,r,`for extension:`,i)}n.set(o,r)}let s=n.get(o);if(s)return s}}function Se(e,t){let n=d.default.extname(e),r=oe(e,t);if(r!==void 0)return r??void 0;let i=Q(d.default.dirname(e)),a=xe(e);if(a)return a;let o=`No supported tsrx compiler found in workspace for ${e}.`,s=le;for(;s;){let e=[];for(let[t,r,i,a,o=ue]of K){if(!i.includes(n))continue;let c=d.default.join(s,...r);for(let n of o){let r=d.default.join(c,...n);if(u.default.existsSync(r)){e.push([t,r,a]);break}}}if(e.length>0){let t=e.find(([e,,t])=>$(i,e,t))?.[1]??e[0][1];return H(`${o} Using packaged version at ${t}`),t}let t=d.default.dirname(s);if(t===s)break;s=t}}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return pe}});
|
|
10
|
-
+`)}`:``,i=`Unable to resolve tsconfig extends entry ${JSON.stringify(e.extends_value)} in ${e.config_path} while resolving TSRX platform${r}`;throw j(i),Error(i)}return u.state===`declared`?u.value:void 0}const ce=(0,f.createRequire)(require(`url`).pathToFileURL(__filename).href),le=d.default.dirname((0,p.fileURLToPath)(require(`url`).pathToFileURL(__filename).href)),{log:V,logWarning:H,logError:U}=k(`[TSRX Language]`),W=new Set,G=[`.tsrx`],K=[[`@tsrx/ripple`,[`node_modules`,`@tsrx`,`ripple`],[`.tsrx`],[`@tsrx/ripple`,`ripple`,`@ripple-ts/vite-plugin`]],[`@tsrx/react`,[`node_modules`,`@tsrx`,`react`],[`.tsrx`],[`@tsrx/react`,`@tsrx/vite-plugin-react`]],[`@tsrx/solid`,[`node_modules`,`@tsrx`,`solid`],[`.tsrx`],[`@tsrx/solid`,`@tsrx/vite-plugin-solid`]],[`@tsrx/preact`,[`node_modules`,`@tsrx`,`preact`],[`.tsrx`],[`@tsrx/preact`,`@tsrx/vite-plugin-preact`]],[`@tsrx/vue`,[`node_modules`,`@tsrx`,`vue`],[`.tsrx`],[`@tsrx/vue`,`@tsrx/vite-plugin-vue`]],[`@tsrx/hono`,[`node_modules`,`@tsrx`,`hono`],[`.tsrx`],[`@tsrx/hono`,`@tsrx/vite-plugin-hono`]],[`octane`,[`node_modules`,`octane`],[`.tsrx`],[`octane`,`@octanejs/vite-plugin`],[[`dist`,`compiler`,`volar.js`],[`src`,`compiler`,`volar.js`]]]],ue=[[`src`,`index.js`]];function de(e){return G.some(t=>e.endsWith(t))}function fe(e,t=l.default){let n=t.createScanner(t.ScriptTarget.Latest,!0,t.LanguageVariant.JSX,e),r=[];for(let e=n.scan();e!==t.SyntaxKind.EndOfFileToken;e=n.scan())r.push({kind:e,text:n.getTokenText()});let i=[`import`,`.`,`meta`,`.`,`env`,`.`,`platform`,`.`];for(let e=0;e+i.length<r.length;e+=1){if(e>0&&(r[e-1].kind===t.SyntaxKind.DotToken||r[e-1].kind===t.SyntaxKind.QuestionDotToken)||!i.every((t,n)=>r[e+n].text===t))continue;let n=r[e+i.length].text;if(n===`web`||n===`ios`||n===`android`)return!0}return!1}function pe(e={}){V(`Creating TSRX language plugin...`);let t=e.ts??l.default,n={...e,ts:t,configHost:e.configHost??t.sys};return{getLanguageId(e){let t=typeof e==`string`?e:e.fsPath.replace(/\\/g,`/`);if(de(t))return V(`Identified TSRX file:`,t),`tsrx`},createVirtualCode(e,t,r){if(t===`tsrx`){let t=ve(e),i=ye(t,n);if(!i){U(`TSRX compiler not found for file: ${t}`);return}V(`Creating virtual code for:`,t);try{return new q(t,r,i,e=>se(t,{...n,requirePlatformResolution:e}))}catch(e){throw U(`Failed to create virtual code for:`,t,`:`,e),e}}},updateVirtualCode(e,t,n){if(t instanceof q)return V(`Updating existing virtual code for:`,t.fileName),t.update(n),t},typescript:{resolveHiddenExtensions:!0,extraFileExtensions:G.map(e=>({extension:e.slice(1),isMixedContent:!1,scriptKind:7})),getServiceScript(e){for(let t of(0,w.forEachEmbeddedCode)(e))if(t.languageId===`tsrx`)return{code:t,extension:`.tsx`,scriptKind:4}},...process.env.TSRX_TSC===`true`?null:{getExtraServiceScripts(e,t){let n=[];for(let r of(0,w.forEachEmbeddedCode)(t))r.languageId===`typescript`&&n.push({fileName:`${e}.${r.id}.ts`,code:r,extension:`.ts`,scriptKind:l.default.ScriptKind.TS});return n}}}}}var q=class{id=`root`;languageId=`tsrx`;codegenStacks=[];tsrx;platformProvider;generatedCode=``;embeddedCodes=[];mappings=[];fatalErrors=[];usageErrors=[];snapshot;sourceSnapshot;originalCode=``;sourceAst=null;isDotCompletionMode=!1;diagnostics=[];#e=null;#t=null;constructor(e,t,n,r){if(V(`Initializing TSRXVirtualCode for:`,e),this.fileName=e,this.tsrx=n,this.platformProvider=r,this.snapshot=t,this.sourceSnapshot=t,this.originalCode=t.getText(0,t.getLength()),!n||typeof n.compile_to_volar_mappings!=`function`)throw U(`Invalid TSRX compiler - missing compile_to_volar_mappings method`),Error(`Invalid TSRX compiler`);this.update(t)}update(e){V(`Updating virtual code for:`,this.fileName);let t=e.getText(0,e.getLength()),n=e.getChangeRange(this.sourceSnapshot);this.sourceSnapshot=e,this.#e=null,this.#t=null,this.fatalErrors=[],this.usageErrors=[],this.sourceAst=null,this.isDotCompletionMode=!1;let r,i=!1,a=-1;if(V(`changeRange:`,JSON.stringify(n)),n){let e=n.span.start,r=e+n.span.length,o=e+n.newLength,s=this.originalCode.substring(e,r),c=t.substring(e,o);if(V(`Change details:`),V(` Position:`,e,`-`,r,`(length:`,n.span.length,`)`),V(` Old text:`,JSON.stringify(s)),V(` New text:`,JSON.stringify(c),`(length:`,n.newLength,`)`),c.endsWith(`.`)){let e=o>1?t[o-2]:``;V(` Char before dot:`,JSON.stringify(e)),/[$#_\u200C\u200D\p{ID_Continue}\)\]\}]/u.test(e)&&(i=!0,a=o-1,V(`ChangeRange detected dot typed at position`,a))}}try{let e=this.platformProvider?.(fe(t));if(i&&a>=0){this.isDotCompletionMode=!0;let n=t.substring(0,a)+t.substring(a+1);if(V(`Compiling without typed dot at position`,a),r=this.tsrx.compile_to_volar_mappings(n,this.fileName,{loose:!0,platform:e}),V(`Compilation without dot successful`),r&&r.code&&r.mappings.length>0){let e=ge(r,a);e===null?H(`Failed to restore typed dot into transpiled output`):V(`Inserted typed dot at generated position`,e)}}else V(`Compiling TSRX code...`),r=this.tsrx.compile_to_volar_mappings(t,this.fileName,{loose:!0,platform:e}),V(`Compilation successful, generated code length:`,r?.code?.length||0)}catch(e){let t=e;U(`TSRX compilation failed for`,this.fileName,`:`,t),process.env.TSRX_TSC===`true`&&Y(this.fileName,[t]),t.type=`fatal`,this.fatalErrors.push(t)}if(r&&r.code){this.originalCode=t,this.generatedCode=r.code,this.mappings=r.mappings??[],this.usageErrors=r.errors,this.sourceAst=r.sourceAst,process.env.TSRX_TSC===`true`&&r.errors.length>0&&Y(this.fileName,r.errors);let e=r.cssMappings,n=r.scriptMappings??[];if(e.length>0||n.length>0){V(`Creating`,e.length,`CSS and`,n.length,`script embedded codes`);let t=[];for(let n of e)t.push(X(n,`css`));for(let e of n)t.push(X(e,`typescript`));this.embeddedCodes=t}else this.embeddedCodes=[];if(O){V(`CSS embedded codes:`,(this.embeddedCodes||[]).length),V(`Using transpiled code, mapping count:`,this.mappings.length),V(`Original code length:`,t.length),V(`Generated code length:`,this.generatedCode.length),V(`Last 100 chars of original:`,JSON.stringify(t.slice(-100))),V(`Last 200 chars of generated:`,JSON.stringify(this.generatedCode.slice(-200))),V(`Last few mappings:`);let e=Math.max(0,this.mappings.length-5);for(let t=e;t<this.mappings.length;t++){let e=this.mappings[t];V(` Mapping ${t}: source[${e.sourceOffsets[0]}:${e.sourceOffsets[0]+e.lengths[0]}] -> gen[${e.generatedOffsets[0]}:${e.generatedOffsets[0]+e.lengths[0]}], len=${e.lengths[0]}, completion=${e.data?.completion}`)}}this.snapshot={getText:(e,t)=>this.generatedCode.substring(e,t),getLength:()=>this.generatedCode.length,getChangeRange:()=>void 0}}else V(`Compilation failed, only display where the compilation error occurred.`),this.originalCode=t,this.generatedCode=t,this.mappings=[{sourceOffsets:[0],generatedOffsets:[0],lengths:[t.length],generatedLengths:[t.length],data:{completion:!0,verification:!0,customData:{}}}],this.embeddedCodes=[...me(t),...he(t)],this.snapshot={getText:(e,t)=>this.generatedCode.substring(e,t),getLength:()=>this.generatedCode.length,getChangeRange:()=>void 0}}#n(){if(!(this.#e||this.#t)){this.#e=new Map,this.#t=new Map;for(var e,t,n,r,i,a,o,s,c,l=0;l<this.mappings.length;l++)e=this.mappings[l],t=e.generatedOffsets[0],n=e.generatedLengths[0],r=t+n,i=`${t}-${r}`,this.#e.set(i,e),a=e.sourceOffsets[0],o=e.lengths[0],s=a+o,c=`${a}-${s}`,this.#t.set(c,e)}}findMappingByGeneratedRange(e,t){return this.#n(),this.#e.get(`${e}-${t}`)??null}findMappingBySourceRange(e,t){return this.#n(),this.#t.get(`${e}-${t}`)??null}findGeneratedRangeBySourceRange(e,t){let n=null,r=null;for(let i=0;i<this.mappings.length;i++){let a=this.mappings[i],o=a.sourceOffsets[0],s=o+a.lengths[0];s<=e||o>=t||((!n||o<n.sourceOffsets[0])&&(n=a),(!r||s>r.sourceOffsets[0]+r.lengths[0])&&(r=a))}if(!n||!r)return null;let i=n.generatedOffsets[0]+J(e-n.sourceOffsets[0],n.generatedLengths[0]),a=r.generatedOffsets[0]+J(t-r.sourceOffsets[0],r.generatedLengths[0]);return[i,Math.max(a,i+1)]}};function J(e,t){return Math.min(Math.max(e,0),t)}function Y(e,t){for(let n of t){let t=n&&typeof n==`object`&&`message`in n?String(n.message):String(n),r=`${e}\0${t}`;W.has(r)||(W.add(r),console.error(`[tsrx-tsc] ${e}: ${t}`))}}function me(e){let t=[],n=/<style\b((?:[^>"'{}/]|"[^"]*"|'[^']*'|\{(?:[^{}]|\{[^{}]*\})*\}|\/(?!>))*)>([\s\S]*?)<\/style>/gi,r,i=0;for(;(r=n.exec(e))!==null;){let e=r[1],n=r[2],a=r.index+(6+e.length+1),o=n.length,s=`style_${i}`;V(`Extracted CSS region ${i}: offset ${a}, length ${o}`);let c={sourceOffsets:[a],generatedOffsets:[0],lengths:[o],generatedLengths:[o],data:{verification:!0,completion:!0,semantic:!0,navigation:!0,structure:!0,format:!1,customData:{content:n,embeddedId:s}}};t.push(X(c,`css`)),i++}return t.length>0&&V(`Extracted ${t.length} CSS embedded codes from style tags`),t}function X(e,t){let n=e.data?.customData?.content??``;return{id:e.data?.customData?.embeddedId,languageId:t,snapshot:{getText:(e,t)=>n.substring(e,t),getLength:()=>e.lengths[0],getChangeRange:()=>void 0},mappings:[e],embeddedCodes:[]}}function he(e){let t=[],n=/<script\b((?:[^>"'/]|"[^"]*"|'[^']*'|\/(?!>))*)>([\s\S]*?)<\/script>/gi,r,i=0;for(;(r=n.exec(e))!==null;){let e=r[1],n=r[2],a=r.index+(7+e.length+1),o=n.length,s=`script_${i}`;V(`Extracted script region ${i}: offset ${a}, length ${o}`);let c={sourceOffsets:[a],generatedOffsets:[0],lengths:[o],generatedLengths:[o],data:{verification:!0,completion:!0,semantic:!0,navigation:!0,structure:!0,format:!1,customData:{content:n,embeddedId:s}}};t.push(X(c,`typescript`)),i++}return t.length>0&&V(`Extracted ${t.length} script embedded codes from script tags`),t}function ge(e,t){let n=null;for(let r of e.mappings)if(r.sourceOffsets[0]+r.lengths[0]===t){n=r;break}if(!n)return null;let r=n.generatedLengths[0],i=n.generatedOffsets[0]+r;e.code=e.code.substring(0,i)+`.`+e.code.substring(i);let a={sourceOffsets:[t],generatedOffsets:[i],lengths:[1],generatedLengths:[1],data:{...n.data}},o=e.mappings.indexOf(n);e.mappings.splice(o+1,0,a);for(let r of e.mappings)r!==n&&r!==a&&r.generatedOffsets[0]>=i&&(r.generatedOffsets[0]+=1),r!==n&&r!==a&&r.sourceOffsets[0]>=t&&(r.sourceOffsets[0]+=1);return i}const _e=new Map,Z=new Map;function ve(e){return typeof e==`string`?e:e.fsPath.replace(/\\/g,`/`)}function Q(e,t=u.default.existsSync){let n=e,r=[];for(;n;){if(Z.has(n)){let e=Z.get(n)??null;for(let t of r)Z.set(t,e);return e}r.push(n);let e=d.default.join(n,`package.json`);if(t(e))try{let t=JSON.parse(u.default.readFileSync(e,`utf8`)),n=new Set([...Object.keys(t.dependencies??{}),...Object.keys(t.devDependencies??{}),...Object.keys(t.peerDependencies??{}),...Object.keys(t.optionalDependencies??{})]),i={name:typeof t.name==`string`?t.name:null,dependencies:n};for(let e of r)Z.set(e,i);return i}catch{for(let e of r)Z.set(e,null);return null}let i=d.default.dirname(n);if(i===n)break;n=i}for(let e of r)Z.set(e,null);return null}function $(e,t,n){if(!e)return!1;if(e.name===t||n.includes(e.name??``)||e.dependencies.has(t))return!0;for(let t of n)if(e.dependencies.has(t))return!0;return!1}function ye(e,t){let n=Se(e,t);if(n)return be(ce(n))}function be(e){return typeof e?.compile_to_volar_mappings!=`function`&&typeof e?.compileToVolarMappings==`function`?{...e,compile_to_volar_mappings:e.compileToVolarMappings}:e}function xe(e,t=u.default.existsSync,n=_e){let r=e.split(`/`),i=d.default.extname(e);for(let e=r.length-2;e>=0;e--){let a=r.slice(0,e+1).join(`/`),o=a+`\0`+i;if(!n.has(o)){let e=[];for(let[n,r,o,s,c=ue]of K)if(o.includes(i))for(let i of c){let o=[a,...r,...i].join(`/`);if(t(o)){e.push([n,o,s]);break}}let r=null;if(e.length>0){let n=Q(a,t);r=e.find(([e,,t])=>$(n,e,t))?.[1]??e[0][1],V(`Found tsrx compiler at:`,r,`for extension:`,i)}n.set(o,r)}let s=n.get(o);if(s)return s}}function Se(e,t){let n=d.default.extname(e),r=oe(e,t);if(r!==void 0)return r??void 0;let i=Q(d.default.dirname(e)),a=xe(e);if(a)return a;let o=`No supported tsrx compiler found in workspace for ${e}.`,s=le;for(;s;){let e=[];for(let[t,r,i,a,o=ue]of K){if(!i.includes(n))continue;let c=d.default.join(s,...r);for(let n of o){let r=d.default.join(c,...n);if(u.default.existsSync(r)){e.push([t,r,a]);break}}}if(e.length>0){let t=e.find(([e,,t])=>$(i,e,t))?.[1]??e[0][1];return H(`${o} Using packaged version at ${t}`),t}let t=d.default.dirname(s);if(t===s)break;s=t}}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return pe}});
|
|
11
|
-
//# sourceMappingURL=language-CofXAudP.js.map
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
diff --git a/lib/parse/index.js b/lib/parse/index.js
|
|
2
|
-
index 053f059..ec14409 100644
|
|
3
|
-
--- a/lib/parse/index.js
|
|
4
|
-
+++ b/lib/parse/index.js
|
|
5
|
-
@@ -390,6 +390,39 @@ module.exports = function(css, options){
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
+ /**
|
|
10
|
-
+ * Parse layer — block form `@layer name { rules }` (anonymous when the name
|
|
11
|
-
+ * is empty) and statement form `@layer a, b;` (declares order only).
|
|
12
|
-
+ */
|
|
13
|
-
+
|
|
14
|
-
+ function atlayer() {
|
|
15
|
-
+ var pos = position();
|
|
16
|
-
+ var m = match(/^@layer\s*([^{;]*)/);
|
|
17
|
-
+
|
|
18
|
-
+ if (!m) return;
|
|
19
|
-
+
|
|
20
|
-
+ var name = trim(m[1]);
|
|
21
|
-
+
|
|
22
|
-
+ if (match(/^;/)) {
|
|
23
|
-
+ return pos({
|
|
24
|
-
+ type: 'layer',
|
|
25
|
-
+ layer: name
|
|
26
|
-
+ });
|
|
27
|
-
+ }
|
|
28
|
-
+
|
|
29
|
-
+ if (!open()) return error("@layer missing '{'");
|
|
30
|
-
+
|
|
31
|
-
+ var style = comments().concat(rules());
|
|
32
|
-
+
|
|
33
|
-
+ if (!close()) return error("@layer missing '}'");
|
|
34
|
-
+
|
|
35
|
-
+ return pos({
|
|
36
|
-
+ type: 'layer',
|
|
37
|
-
+ layer: name,
|
|
38
|
-
+ rules: style
|
|
39
|
-
+ });
|
|
40
|
-
+ }
|
|
41
|
-
+
|
|
42
|
-
/**
|
|
43
|
-
* Parse custom-media.
|
|
44
|
-
*/
|
|
45
|
-
@@ -533,6 +566,7 @@ module.exports = function(css, options){
|
|
46
|
-
|
|
47
|
-
return atkeyframes()
|
|
48
|
-
|| atmedia()
|
|
49
|
-
+ || atlayer()
|
|
50
|
-
|| atcustommedia()
|
|
51
|
-
|| atsupports()
|
|
52
|
-
|| atimport()
|