@typemf/vscode-runtime 0.6.0 → 0.8.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/dist/host.cjs +45 -6
- package/dist/host.cjs.map +1 -1
- package/dist/host.js +45 -6
- package/dist/host.js.map +1 -1
- package/package.json +9 -9
package/dist/host.cjs
CHANGED
|
@@ -46,7 +46,7 @@ var json = __toESM(require("@typemf/json"), 1);
|
|
|
46
46
|
var node = __toESM(require("@typemf/node"), 1);
|
|
47
47
|
var xmi = __toESM(require("@typemf/xmi"), 1);
|
|
48
48
|
var import_node_module = require("module");
|
|
49
|
-
var
|
|
49
|
+
var vscode3 = __toESM(require("vscode"), 1);
|
|
50
50
|
|
|
51
51
|
// src/load-ecore-mappings.ts
|
|
52
52
|
var import_core = require("@typemf/core");
|
|
@@ -89,7 +89,7 @@ async function loadConfiguredEcoreMappings(workspaceFolders, runtime) {
|
|
|
89
89
|
if (!runtime.packageRegistry.containsPackage(import_core.EcorePackageImpl.eINSTANCE.getNsURI() ?? "")) {
|
|
90
90
|
runtime.packageRegistry.register(import_core.EcorePackageImpl.eINSTANCE);
|
|
91
91
|
}
|
|
92
|
-
if (!runtime.uriConverterRegistry.
|
|
92
|
+
if (!runtime.uriConverterRegistry.getConverter(import_core.URI.createFileURI("/"))) {
|
|
93
93
|
runtime.uriConverterRegistry.register(new import_node.NodeFileUriConverter());
|
|
94
94
|
}
|
|
95
95
|
const resourceSet = runtime.createResourceSet();
|
|
@@ -271,25 +271,64 @@ var TypeMfRuntime = class {
|
|
|
271
271
|
}
|
|
272
272
|
};
|
|
273
273
|
|
|
274
|
+
// src/vscode-workspace-file-system.ts
|
|
275
|
+
var vscode2 = __toESM(require("vscode"), 1);
|
|
276
|
+
var vscodeWorkspaceFileSystem = {
|
|
277
|
+
readFile: (uri) => Promise.resolve(vscode2.workspace.fs.readFile(vscode2.Uri.parse(uri))),
|
|
278
|
+
async writeFile(uri, content) {
|
|
279
|
+
const target = vscode2.Uri.parse(uri);
|
|
280
|
+
await vscode2.workspace.fs.createDirectory(vscode2.Uri.joinPath(target, ".."));
|
|
281
|
+
await vscode2.workspace.fs.writeFile(target, content);
|
|
282
|
+
},
|
|
283
|
+
async exists(uri) {
|
|
284
|
+
try {
|
|
285
|
+
await vscode2.workspace.fs.stat(vscode2.Uri.parse(uri));
|
|
286
|
+
return true;
|
|
287
|
+
} catch {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
// src/workspace-file-system-uri-converter.ts
|
|
294
|
+
var WorkspaceFileSystemUriConverter = class {
|
|
295
|
+
constructor(fs) {
|
|
296
|
+
this.fs = fs;
|
|
297
|
+
}
|
|
298
|
+
fs;
|
|
299
|
+
canHandle(uri) {
|
|
300
|
+
return !uri.isRelative();
|
|
301
|
+
}
|
|
302
|
+
readBinary(uri) {
|
|
303
|
+
return this.fs.readFile(uri.trimFragment().toString());
|
|
304
|
+
}
|
|
305
|
+
writeBinary(uri, content) {
|
|
306
|
+
return this.fs.writeFile(uri.trimFragment().toString(), content);
|
|
307
|
+
}
|
|
308
|
+
exists(uri) {
|
|
309
|
+
return this.fs.exists(uri.trimFragment().toString());
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
|
|
274
313
|
// src/activate-runtime.ts
|
|
275
314
|
async function activateRuntime(context, versions) {
|
|
276
315
|
const runtime = new TypeMfRuntime();
|
|
277
|
-
runtime.uriConverterRegistry.register(new
|
|
316
|
+
runtime.uriConverterRegistry.register(new WorkspaceFileSystemUriConverter(vscodeWorkspaceFileSystem));
|
|
278
317
|
runtime.modules.provide("@typemf/core", versions["@typemf/core"], core);
|
|
279
318
|
runtime.modules.provide("@typemf/json", versions["@typemf/json"], json);
|
|
280
319
|
runtime.modules.provide("@typemf/node", versions["@typemf/node"], node);
|
|
281
320
|
runtime.modules.provide("@typemf/xmi", versions["@typemf/xmi"], xmi);
|
|
282
321
|
const scanned = /* @__PURE__ */ new Set();
|
|
283
322
|
const scanNewExtensions = () => {
|
|
284
|
-
const added =
|
|
323
|
+
const added = vscode3.extensions.all.filter((extension) => !scanned.has(extension.id));
|
|
285
324
|
for (const extension of added) scanned.add(extension.id);
|
|
286
325
|
for (const problem of registerManifestModules(runtime, added, loadCommonJsFile)) {
|
|
287
326
|
console.warn(`TypeMF runtime: ${problem}`);
|
|
288
327
|
}
|
|
289
328
|
};
|
|
290
329
|
scanNewExtensions();
|
|
291
|
-
context.subscriptions.push(
|
|
292
|
-
await loadConfiguredEcoreMappings(
|
|
330
|
+
context.subscriptions.push(vscode3.extensions.onDidChange(scanNewExtensions));
|
|
331
|
+
await loadConfiguredEcoreMappings(vscode3.workspace.workspaceFolders ?? [], runtime);
|
|
293
332
|
return runtime;
|
|
294
333
|
}
|
|
295
334
|
function loadCommonJsFile(absolutePath) {
|
package/dist/host.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/host.ts","../src/activate-runtime.ts","../src/load-ecore-mappings.ts","../src/ecore-mappings.ts","../src/manifest-modules.ts","../src/typemf-runtime.ts","../src/module-host.ts","../src/register-defaults.ts","../src/register-ecore-metamodel.ts"],"sourcesContent":["export * from './activate-runtime.js';\nexport * from './ecore-mappings.js';\nexport * from './manifest-modules.js';\nexport * from './module-host.js';\nexport * from './register-defaults.js';\nexport * from './register-ecore-metamodel.js';\nexport * from './typemf-runtime.js';\n","import * as core from '@typemf/core';\nimport * as json from '@typemf/json';\nimport * as node from '@typemf/node';\nimport * as xmi from '@typemf/xmi';\nimport { createRequire } from 'node:module';\nimport * as vscode from 'vscode';\nimport { loadConfiguredEcoreMappings } from './load-ecore-mappings.js';\nimport { registerManifestModules } from './manifest-modules.js';\nimport type { TypeMfRuntimeApi } from './api.js';\nimport { TypeMfRuntime } from './typemf-runtime.js';\n\n/** Versions of the TypeMF libraries bundled into the runtime extension. */\nexport interface BuiltinModuleVersions {\n '@typemf/core': string;\n '@typemf/json': string;\n '@typemf/node': string;\n '@typemf/xmi': string;\n}\n\n/**\n * Creates the shared runtime: provides the bundled TypeMF libraries as shared modules, declares\n * the modules of all installed extensions (and of extensions installed later), and loads the\n * `typemf.ecoreMappings` setting. Called by the runtime extension's `activate()`.\n */\nexport async function activateRuntime(\n context: vscode.ExtensionContext,\n versions: BuiltinModuleVersions\n): Promise<TypeMfRuntimeApi> {\n const runtime = new TypeMfRuntime();\n runtime.uriConverterRegistry.register(new node.NodeFileUriConverter());\n runtime.modules.provide('@typemf/core', versions['@typemf/core'], core);\n runtime.modules.provide('@typemf/json', versions['@typemf/json'], json);\n runtime.modules.provide('@typemf/node', versions['@typemf/node'], node);\n runtime.modules.provide('@typemf/xmi', versions['@typemf/xmi'], xmi);\n\n const scanned = new Set<string>();\n const scanNewExtensions = () => {\n const added = vscode.extensions.all.filter((extension) => !scanned.has(extension.id));\n for (const extension of added) scanned.add(extension.id);\n for (const problem of registerManifestModules(runtime, added, loadCommonJsFile)) {\n console.warn(`TypeMF runtime: ${problem}`);\n }\n };\n scanNewExtensions();\n context.subscriptions.push(vscode.extensions.onDidChange(scanNewExtensions));\n\n await loadConfiguredEcoreMappings(vscode.workspace.workspaceFolders ?? [], runtime);\n return runtime;\n}\n\nfunction loadCommonJsFile(absolutePath: string): unknown {\n return createRequire(absolutePath)(absolutePath);\n}\n","import { EcorePackageImpl, isEPackage, URI } from '@typemf/core';\nimport { NodeFileUriConverter } from '@typemf/node';\nimport { join } from 'node:path';\nimport * as vscode from 'vscode';\nimport { EcoreMappingEntry, resolveMappings } from './ecore-mappings.js';\nimport type { TypeMfRuntimeApi } from './api.js';\n\n/**\n * Reads the `typemf.ecoreMappings` setting (merged across scopes, see resolveMappings), loads\n * each entry's .ecore file, and registers its root EPackage into `runtime.packageRegistry`.\n *\n * A real `vscode` value import, unlike typemf-runtime.ts/register-defaults.ts/ecore-mappings.ts -\n * this genuinely needs vscode.workspace.getConfiguration() and real filesystem access, so it's\n * kept in its own file rather than folded into those, the same reasoning extension.ts's own\n * `import type` split was built around.\n */\nexport async function loadConfiguredEcoreMappings(\n workspaceFolders: readonly vscode.WorkspaceFolder[],\n runtime: TypeMfRuntimeApi\n): Promise<void> {\n const firstFolder = workspaceFolders[0];\n\n // getConfiguration's second argument is what makes workspaceFolderValue resolve to the RIGHT\n // folder's own settings in a multi-root workspace - and \"always resolve relative paths against\n // the first workspace folder\" (decided earlier) means that's also the one folder whose\n // workspaceFolderValue is relevant here, not any other folder's.\n const inspected = vscode.workspace\n .getConfiguration('typemf', firstFolder?.uri)\n .inspect<EcoreMappingEntry[]>('ecoreMappings');\n const mappings = resolveMappings(inspected ?? {});\n if (mappings.length === 0) return;\n\n if (!firstFolder) {\n console.warn(\n `typemf.ecoreMappings: ${mappings.length} entr${mappings.length === 1 ? 'y' : 'ies'} configured, but no workspace folder is open to resolve relative paths against - skipping.`\n );\n return;\n }\n\n // Ecore's own metamodel must be registered before any .ecore file's xsi:type=\"ecore:EClass\"\n // etc. can be interpreted at all - always safe and correct to register unconditionally, since\n // Ecore's own nsURI (http://www.eclipse.org/emf/2002/Ecore) never collides with a real domain\n // metamodel's, and it's always live once @typemf/core is loaded regardless (the self-hosted\n // swap made that permanent - see @typemf/generator's NOTES.md).\n if (!runtime.packageRegistry.containsPackage(EcorePackageImpl.eINSTANCE.getNsURI() ?? '')) {\n runtime.packageRegistry.register(EcorePackageImpl.eINSTANCE);\n }\n\n // A file:// converter is needed to actually read .ecore files from disk. The extension host\n // (unlike a webview) is always Node-capable, so registering this into the SHARED\n // uriConverterRegistry - not a separate, throwaway one just for this loading step - is safe,\n // and lets every other extension sharing this runtime benefit from file:// support too, not\n // just this one loading pass.\n if (!runtime.uriConverterRegistry.getConverters().some((converter) => converter instanceof NodeFileUriConverter)) {\n runtime.uriConverterRegistry.register(new NodeFileUriConverter());\n }\n\n const resourceSet = runtime.createResourceSet();\n\n for (const mapping of mappings) {\n try {\n const absolutePath = join(firstFolder.uri.fsPath, mapping.ecoreFile);\n const resource = await resourceSet.getResource(URI.createFileURI(absolutePath), true);\n const contents = resource?.getContents();\n // EList.get(0) throws on an empty list rather than returning undefined - check isEmpty()\n // first so a load that produced no root reports the clear message below, not a confusing\n // \"index out of bounds\" one from the catch block.\n const root = contents && !contents.isEmpty() ? contents.get(0) : undefined;\n if (!root || !isEPackage(root)) {\n console.warn(\n `typemf.ecoreMappings: entry for '${mapping.nsURI}' (${mapping.ecoreFile}) did not load a valid EPackage - skipping.`\n );\n continue;\n }\n runtime.packageRegistry.register(root);\n } catch (err) {\n console.warn(\n `typemf.ecoreMappings: failed to load entry for '${mapping.nsURI}' (${mapping.ecoreFile}): ${(err as Error).message}`\n );\n }\n }\n}\n","/** One entry of the `typemf.ecoreMappings` VS Code setting. */\nexport interface EcoreMappingEntry {\n /** The EPackage nsURI this mapping registers. */\n nsURI: string;\n /** Path to the .ecore file, resolved relative to the first workspace folder. */\n ecoreFile: string;\n}\n\n/**\n * The three per-scope arrays VS Code's own `WorkspaceConfiguration.inspect()` returns for an\n * array-typed setting. Deliberately a plain, local interface - not `vscode`'s own\n * `InspectionResult<T>` type - so this file (and resolveMappings itself) stays usable and\n * unit-testable with no VS Code present at all, matching typemf-runtime.ts/register-defaults.ts.\n */\nexport interface InspectedEcoreMappings {\n globalValue?: EcoreMappingEntry[];\n workspaceValue?: EcoreMappingEntry[];\n workspaceFolderValue?: EcoreMappingEntry[];\n}\n\n/**\n * Merges the three scopes VS Code's own array-typed settings do NOT merge automatically\n * (confirmed directly against VS Code's own documentation: \"Only object value types are merged\n * and all other value types are overridden\" - arrays fall under \"other\"). Uses VS Code's real,\n * general settings precedence - workspaceFolder overrides workspace overrides user (global) - not\n * an invented order.\n *\n * For each nsURI, only the first occurrence (in that precedence order) is kept; every later\n * duplicate - whether from a less-specific scope or a second entry within the very same array -\n * is dropped with a warning rather than silently overwriting or being silently ignored.\n */\nexport function resolveMappings(inspected: InspectedEcoreMappings): EcoreMappingEntry[] {\n const ordered = [\n ...(inspected.workspaceFolderValue ?? []),\n ...(inspected.workspaceValue ?? []),\n ...(inspected.globalValue ?? []),\n ];\n const seen = new Map<string, EcoreMappingEntry>();\n for (const entry of ordered) {\n if (seen.has(entry.nsURI)) {\n console.warn(\n `typemf.ecoreMappings: duplicate entry for nsURI '${entry.nsURI}' - keeping the more specific (or earlier-declared) one, ignoring this one ('${entry.ecoreFile}').`\n );\n continue;\n }\n seen.set(entry.nsURI, entry);\n }\n return [...seen.values()];\n}\n","import { EPackage, isEPackage } from '@typemf/core';\nimport { join } from 'node:path';\nimport type { TypeMfRuntime } from './typemf-runtime.js';\n\n/** One entry of `typemf.modules` in an extension's package.json. */\nexport interface ManifestModuleEntry {\n /** Path to the module's CommonJS bundle, relative to the extension folder. */\n path: string;\n version: string;\n /** Maps each nsURI the module contains to the export holding its EPackage (or a class with a static `eINSTANCE`). */\n packages?: Record<string, string>;\n}\n\n/** The parts of a `vscode.Extension` this file needs. */\nexport interface ExtensionInfo {\n readonly id: string;\n readonly extensionPath: string;\n readonly packageJSON: unknown;\n}\n\n/**\n * Declares every module listed under `typemf.modules` in the extensions' manifests in\n * `runtime.modules`, and registers a descriptor in `runtime.packageRegistry` for each nsURI they\n * contain. `loadFile` loads a module bundle by absolute path. Returns one message per skipped entry.\n */\nexport function registerManifestModules(\n runtime: TypeMfRuntime,\n extensions: readonly ExtensionInfo[],\n loadFile: (absolutePath: string) => unknown\n): string[] {\n const problems: string[] = [];\n for (const extension of extensions) {\n const modules = (extension.packageJSON as { typemf?: { modules?: unknown } } | undefined)?.typemf?.modules;\n if (modules === undefined) continue;\n if (typeof modules !== 'object' || modules === null) {\n problems.push(`${extension.id}: 'typemf.modules' must be an object.`);\n continue;\n }\n for (const [name, raw] of Object.entries(modules)) {\n const entry = raw as Partial<ManifestModuleEntry>;\n if (typeof entry.path !== 'string' || typeof entry.version !== 'string') {\n problems.push(`${extension.id}: module '${name}' needs a string 'path' and 'version'.`);\n continue;\n }\n const absolutePath = join(extension.extensionPath, entry.path);\n try {\n runtime.modules.declare({\n name,\n version: entry.version,\n provider: extension.id,\n load: () => loadFile(absolutePath),\n });\n } catch (err) {\n problems.push(`${extension.id}: ${(err as Error).message}`);\n continue;\n }\n for (const [nsURI, exportName] of Object.entries(entry.packages ?? {})) {\n if (runtime.packageRegistry.containsPackage(nsURI)) {\n problems.push(\n `${extension.id}: nsURI '${nsURI}' of module '${name}' is already registered; keeping the existing registration.`\n );\n continue;\n }\n runtime.packageRegistry.registerDescriptor(nsURI, () =>\n packageFromExport(runtime.modules.require(name, entry.version!), name, exportName)\n );\n }\n }\n }\n return problems;\n}\n\nfunction packageFromExport(module: unknown, moduleName: string, exportName: string): EPackage {\n const exported = (module as Record<string, unknown> | undefined)?.[exportName] as { eINSTANCE?: unknown } | undefined;\n const pkg = exported?.eINSTANCE ?? exported;\n if (!isEPackage(pkg)) {\n throw new Error(\n `Export '${exportName}' of module '${moduleName}' is neither an EPackage nor a class with a static EPackage 'eINSTANCE'.`\n );\n }\n return pkg;\n}\n","import {\n EPackageRegistry,\n EPackageRegistryImpl,\n ResourceFactoryRegistry,\n ResourceFactoryRegistryImpl,\n ResourceSet,\n ResourceSetImpl,\n UriConverterRegistry,\n UriConverterRegistryImpl,\n} from '@typemf/core';\nimport type { TypeMfRuntimeApi } from './api.js';\nimport { ModuleHost } from './module-host.js';\nimport { registerDefaults } from './register-defaults.js';\nimport { registerEcoreMetamodel } from './register-ecore-metamodel.js';\n\nexport interface TypeMfRuntimeOptions {\n /**\n * Whether to register the json/xmi/ecore formats and Ecore's own metamodel. Defaults to true.\n */\n registerDefaults?: boolean;\n}\n\nexport class TypeMfRuntime implements TypeMfRuntimeApi {\n readonly packageRegistry: EPackageRegistry = new EPackageRegistryImpl();\n readonly resourceFactoryRegistry: ResourceFactoryRegistry = new ResourceFactoryRegistryImpl();\n readonly uriConverterRegistry: UriConverterRegistry = new UriConverterRegistryImpl();\n readonly modules = new ModuleHost();\n\n constructor(options: TypeMfRuntimeOptions = {}) {\n if (options.registerDefaults ?? true) {\n registerDefaults(this.resourceFactoryRegistry);\n registerEcoreMetamodel(this.packageRegistry);\n }\n }\n\n createResourceSet(): ResourceSet {\n return new ResourceSetImpl(this.packageRegistry, this.resourceFactoryRegistry, this.uriConverterRegistry);\n }\n\n requireModule(name: string, range: string): unknown {\n return this.modules.require(name, range);\n }\n}\n","import semver from 'semver';\n\n/** A module that an extension declares in its manifest; loaded on its first request. */\nexport interface ModuleDeclaration {\n readonly name: string;\n readonly version: string;\n /** The id of the extension that declares the module. */\n readonly provider: string;\n readonly load: () => unknown;\n}\n\ninterface ModuleEntry {\n readonly version: string;\n readonly provider: string;\n readonly load: () => unknown;\n loaded?: { value: unknown };\n}\n\n/**\n * Holds exactly one instance of every shared module, keyed by npm package name. Modules are either\n * provided as already-loaded objects or declared with a loader that runs on the first request.\n */\nexport class ModuleHost {\n private readonly entries = new Map<string, ModuleEntry>();\n private readonly conflicts = new Map<string, string[]>();\n\n /** Adds an already-loaded module. */\n provide(name: string, version: string, module: unknown, provider = 'typemf.vscode-runtime'): void {\n this.add(name, { version, provider, load: () => module, loaded: { value: module } });\n }\n\n /** Adds a module that is loaded on its first request. */\n declare(declaration: ModuleDeclaration): void {\n if (!semver.valid(declaration.version)) {\n throw new Error(\n `Module '${declaration.name}' from '${declaration.provider}' has an invalid version '${declaration.version}'.`\n );\n }\n this.add(declaration.name, {\n version: declaration.version,\n provider: declaration.provider,\n load: declaration.load,\n });\n }\n\n has(name: string): boolean {\n return this.entries.has(name) || this.conflicts.has(name);\n }\n\n /** The module `name`, if its version satisfies `range`. Throws otherwise. */\n require(name: string, range: string): unknown {\n const providers = this.conflicts.get(name);\n if (providers) {\n throw new Error(\n `Module '${name}' is provided by more than one extension (${providers.join(', ')}); only one provider is allowed.`\n );\n }\n const entry = this.entries.get(name);\n if (!entry) {\n throw new Error(`No installed extension provides module '${name}'.`);\n }\n if (!semver.satisfies(entry.version, range, { includePrerelease: true })) {\n throw new Error(\n `Module '${name}' ${entry.version} (from '${entry.provider}') does not satisfy the requested range '${range}'.`\n );\n }\n if (!entry.loaded) {\n entry.loaded = { value: entry.load() };\n }\n return entry.loaded.value;\n }\n\n private add(name: string, entry: ModuleEntry): void {\n const conflict = this.conflicts.get(name);\n if (conflict) {\n conflict.push(entry.provider);\n return;\n }\n const existing = this.entries.get(name);\n if (existing) {\n this.entries.delete(name);\n this.conflicts.set(name, [existing.provider, entry.provider]);\n return;\n }\n this.entries.set(name, entry);\n }\n}\n","import { ResourceFactoryRegistry } from '@typemf/core';\nimport { registerJsonFormat } from '@typemf/json';\nimport { registerXmiFormat } from '@typemf/xmi';\n\n/**\n * Registers the two formats that are safe in every environment this runtime runs in - the\n * extension host (Node) and a webview (browser), both of which need to work since a shared\n * runtime instance is used from both:\n *\n * - \"json\" (@typemf/json) - JSON.parse/stringify, no environment dependency at all.\n * - \"xmi\" and \"ecore\" (@typemf/xmi) - genuine XML parsing, but @typemf/xmi's own parseXmlDocument\n * feature-detects the native browser DOMParser first and only falls back to a dynamic\n * `import('@xmldom/xmldom')` when that's absent (Node) - confirmed by reading that code\n * directly, not assumed, so this is safe to call unconditionally here.\n *\n * Deliberately does NOT register anything into a UriConverterRegistry, and never will from this\n * function specifically: every concrete UriConverter (e.g. @typemf/node's fs-backed one) is tied\n * to one specific environment, and this function's whole point is to only register things that\n * work everywhere this runtime runs. A Node-only or browser-only converter gets registered by\n * whoever assembles the runtime for that specific environment, not by this shared default.\n *\n * Exported standalone (not just called internally by TypeMfRuntime) so a plain Node script, test,\n * or any other consumer of @typemf/core's ResourceFactoryRegistry can opt into the same defaults\n * without needing @typemf/vscode-runtime or VS Code at all.\n */\nexport function registerDefaults(registry: ResourceFactoryRegistry): void {\n registerJsonFormat(registry);\n registerXmiFormat(registry);\n}\n","import { EcorePackageImpl, EPackageRegistry } from '@typemf/core';\n\n/**\n * Registers Ecore's own metamodel (EClass, EAttribute, EPackage, ...) into `registry` - a\n * deliberate, narrow exception to EPackageRegistry's own \"nothing pre-registered\" design: Ecore\n * itself is foundational, not an arbitrary domain metamodel a dependent extension opts into. Every\n * .ecore file needs it just to be parsed at all, and it's part of the modeling language itself,\n * not something layered on top of it.\n *\n * Without this, opening or creating an instance of Ecore's own classes (e.g. editing a .ecore file\n * directly) had no real path through the \"registered metamodel\" flow at all - it could only ever\n * go through the dynamic .ecore-file picker, loading a fresh, throwaway copy of Ecore's own\n * metamodel each time rather than using the one, real, already-correct EcorePackageImpl.eINSTANCE\n * every generated package already depends on.\n *\n * Exported standalone (not just called internally by TypeMfRuntime), matching register-defaults.ts's\n * own reasoning: a plain Node script, test, or any other consumer of @typemf/core's\n * EPackageRegistry can opt into this without needing @typemf/vscode-runtime or VS Code at all.\n */\nexport function registerEcoreMetamodel(registry: EPackageRegistry): void {\n registry.register(EcorePackageImpl.eINSTANCE);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,WAAsB;AACtB,WAAsB;AACtB,WAAsB;AACtB,UAAqB;AACrB,yBAA8B;AAC9B,IAAAA,UAAwB;;;ACLxB,kBAAkD;AAClD,kBAAqC;AACrC,uBAAqB;AACrB,aAAwB;;;AC4BjB,SAAS,gBAAgB,WAAwD;AACtF,QAAM,UAAU;AAAA,IACd,GAAI,UAAU,wBAAwB,CAAC;AAAA,IACvC,GAAI,UAAU,kBAAkB,CAAC;AAAA,IACjC,GAAI,UAAU,eAAe,CAAC;AAAA,EAChC;AACA,QAAM,OAAO,oBAAI,IAA+B;AAChD,aAAW,SAAS,SAAS;AAC3B,QAAI,KAAK,IAAI,MAAM,KAAK,GAAG;AACzB,cAAQ;AAAA,QACN,oDAAoD,MAAM,KAAK,gFAAgF,MAAM,SAAS;AAAA,MAChK;AACA;AAAA,IACF;AACA,SAAK,IAAI,MAAM,OAAO,KAAK;AAAA,EAC7B;AACA,SAAO,CAAC,GAAG,KAAK,OAAO,CAAC;AAC1B;;;ADhC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BAAiB,KAAK,uBAAuB;AAC7C,6BAAuB,KAAK,eAAe;AAAA,IAC7C;AAAA,EACF;AAAA,EAEA,oBAAiC;AAC/B,WAAO,IAAI,6BAAgB,KAAK,iBAAiB,KAAK,yBAAyB,KAAK,oBAAoB;AAAA,EAC1G;AAAA,EAEA,cAAc,MAAc,OAAwB;AAClD,WAAO,KAAK,QAAQ,QAAQ,MAAM,KAAK;AAAA,EACzC;AACF;;;AJlBA,eAAsB,gBACpB,SACA,UAC2B;AAC3B,QAAM,UAAU,IAAI,cAAc;AAClC,UAAQ,qBAAqB,SAAS,IAAS,0BAAqB,CAAC;AACrE,UAAQ,QAAQ,QAAQ,gBAAgB,SAAS,cAAc,GAAG,IAAI;AACtE,UAAQ,QAAQ,QAAQ,gBAAgB,SAAS,cAAc,GAAG,IAAI;AACtE,UAAQ,QAAQ,QAAQ,gBAAgB,SAAS,cAAc,GAAG,IAAI;AACtE,UAAQ,QAAQ,QAAQ,eAAe,SAAS,aAAa,GAAG,GAAG;AAEnE,QAAM,UAAU,oBAAI,IAAY;AAChC,QAAM,oBAAoB,MAAM;AAC9B,UAAM,QAAe,mBAAW,IAAI,OAAO,CAAC,cAAc,CAAC,QAAQ,IAAI,UAAU,EAAE,CAAC;AACpF,eAAW,aAAa,MAAO,SAAQ,IAAI,UAAU,EAAE;AACvD,eAAW,WAAW,wBAAwB,SAAS,OAAO,gBAAgB,GAAG;AAC/E,cAAQ,KAAK,mBAAmB,OAAO,EAAE;AAAA,IAC3C;AAAA,EACF;AACA,oBAAkB;AAClB,UAAQ,cAAc,KAAY,mBAAW,YAAY,iBAAiB,CAAC;AAE3E,QAAM,4BAAmC,kBAAU,oBAAoB,CAAC,GAAG,OAAO;AAClF,SAAO;AACT;AAEA,SAAS,iBAAiB,cAA+B;AACvD,aAAO,kCAAc,YAAY,EAAE,YAAY;AACjD;","names":["vscode","import_core","import_node_path","extensions","module","import_core","module","semver","import_core"]}
|
|
1
|
+
{"version":3,"sources":["../src/host.ts","../src/activate-runtime.ts","../src/load-ecore-mappings.ts","../src/ecore-mappings.ts","../src/manifest-modules.ts","../src/typemf-runtime.ts","../src/module-host.ts","../src/register-defaults.ts","../src/register-ecore-metamodel.ts","../src/vscode-workspace-file-system.ts","../src/workspace-file-system-uri-converter.ts"],"sourcesContent":["export * from './activate-runtime.js';\nexport * from './ecore-mappings.js';\nexport * from './manifest-modules.js';\nexport * from './module-host.js';\nexport * from './register-defaults.js';\nexport * from './register-ecore-metamodel.js';\nexport * from './typemf-runtime.js';\n","import * as core from '@typemf/core';\nimport * as json from '@typemf/json';\nimport * as node from '@typemf/node';\nimport * as xmi from '@typemf/xmi';\nimport { createRequire } from 'node:module';\nimport * as vscode from 'vscode';\nimport { loadConfiguredEcoreMappings } from './load-ecore-mappings.js';\nimport { registerManifestModules } from './manifest-modules.js';\nimport type { TypeMfRuntimeApi } from './api.js';\nimport { TypeMfRuntime } from './typemf-runtime.js';\nimport { vscodeWorkspaceFileSystem } from './vscode-workspace-file-system.js';\nimport { WorkspaceFileSystemUriConverter } from './workspace-file-system-uri-converter.js';\n\n/** Versions of the TypeMF libraries bundled into the runtime extension. */\nexport interface BuiltinModuleVersions {\n '@typemf/core': string;\n '@typemf/json': string;\n '@typemf/node': string;\n '@typemf/xmi': string;\n}\n\n/**\n * Creates the shared runtime: provides the bundled TypeMF libraries as shared modules, declares\n * the modules of all installed extensions (and of extensions installed later), and loads the\n * `typemf.ecoreMappings` setting. Called by the runtime extension's `activate()`.\n */\nexport async function activateRuntime(\n context: vscode.ExtensionContext,\n versions: BuiltinModuleVersions\n): Promise<TypeMfRuntimeApi> {\n const runtime = new TypeMfRuntime();\n runtime.uriConverterRegistry.register(new WorkspaceFileSystemUriConverter(vscodeWorkspaceFileSystem));\n runtime.modules.provide('@typemf/core', versions['@typemf/core'], core);\n runtime.modules.provide('@typemf/json', versions['@typemf/json'], json);\n runtime.modules.provide('@typemf/node', versions['@typemf/node'], node);\n runtime.modules.provide('@typemf/xmi', versions['@typemf/xmi'], xmi);\n\n const scanned = new Set<string>();\n const scanNewExtensions = () => {\n const added = vscode.extensions.all.filter((extension) => !scanned.has(extension.id));\n for (const extension of added) scanned.add(extension.id);\n for (const problem of registerManifestModules(runtime, added, loadCommonJsFile)) {\n console.warn(`TypeMF runtime: ${problem}`);\n }\n };\n scanNewExtensions();\n context.subscriptions.push(vscode.extensions.onDidChange(scanNewExtensions));\n\n await loadConfiguredEcoreMappings(vscode.workspace.workspaceFolders ?? [], runtime);\n return runtime;\n}\n\nfunction loadCommonJsFile(absolutePath: string): unknown {\n return createRequire(absolutePath)(absolutePath);\n}\n","import { EcorePackageImpl, isEPackage, URI } from '@typemf/core';\nimport { NodeFileUriConverter } from '@typemf/node';\nimport { join } from 'node:path';\nimport * as vscode from 'vscode';\nimport { EcoreMappingEntry, resolveMappings } from './ecore-mappings.js';\nimport type { TypeMfRuntimeApi } from './api.js';\n\n/**\n * Reads the `typemf.ecoreMappings` setting (merged across scopes, see resolveMappings), loads\n * each entry's .ecore file, and registers its root EPackage into `runtime.packageRegistry`.\n *\n * A real `vscode` value import, unlike typemf-runtime.ts/register-defaults.ts/ecore-mappings.ts -\n * this genuinely needs vscode.workspace.getConfiguration() and real filesystem access, so it's\n * kept in its own file rather than folded into those, the same reasoning extension.ts's own\n * `import type` split was built around.\n */\nexport async function loadConfiguredEcoreMappings(\n workspaceFolders: readonly vscode.WorkspaceFolder[],\n runtime: TypeMfRuntimeApi\n): Promise<void> {\n const firstFolder = workspaceFolders[0];\n\n // getConfiguration's second argument is what makes workspaceFolderValue resolve to the RIGHT\n // folder's own settings in a multi-root workspace - and \"always resolve relative paths against\n // the first workspace folder\" (decided earlier) means that's also the one folder whose\n // workspaceFolderValue is relevant here, not any other folder's.\n const inspected = vscode.workspace\n .getConfiguration('typemf', firstFolder?.uri)\n .inspect<EcoreMappingEntry[]>('ecoreMappings');\n const mappings = resolveMappings(inspected ?? {});\n if (mappings.length === 0) return;\n\n if (!firstFolder) {\n console.warn(\n `typemf.ecoreMappings: ${mappings.length} entr${mappings.length === 1 ? 'y' : 'ies'} configured, but no workspace folder is open to resolve relative paths against - skipping.`\n );\n return;\n }\n\n // Ecore's own metamodel must be registered before any .ecore file's xsi:type=\"ecore:EClass\"\n // etc. can be interpreted at all - always safe and correct to register unconditionally, since\n // Ecore's own nsURI (http://www.eclipse.org/emf/2002/Ecore) never collides with a real domain\n // metamodel's, and it's always live once @typemf/core is loaded regardless (the self-hosted\n // swap made that permanent - see @typemf/generator's NOTES.md).\n if (!runtime.packageRegistry.containsPackage(EcorePackageImpl.eINSTANCE.getNsURI() ?? '')) {\n runtime.packageRegistry.register(EcorePackageImpl.eINSTANCE);\n }\n\n // A file:// converter is needed to actually read .ecore files from disk - normally already\n // registered by activateRuntime (the workspace file system one); this is the fallback when\n // nothing handles file:// yet. The extension host (unlike a webview) is always Node-capable, so\n // registering it into the SHARED uriConverterRegistry - not a separate, throwaway one just for\n // this loading step - is safe, and lets every other extension sharing this runtime benefit from\n // file:// support too, not just this one loading pass.\n if (!runtime.uriConverterRegistry.getConverter(URI.createFileURI('/'))) {\n runtime.uriConverterRegistry.register(new NodeFileUriConverter());\n }\n\n const resourceSet = runtime.createResourceSet();\n\n for (const mapping of mappings) {\n try {\n const absolutePath = join(firstFolder.uri.fsPath, mapping.ecoreFile);\n const resource = await resourceSet.getResource(URI.createFileURI(absolutePath), true);\n const contents = resource?.getContents();\n // EList.get(0) throws on an empty list rather than returning undefined - check isEmpty()\n // first so a load that produced no root reports the clear message below, not a confusing\n // \"index out of bounds\" one from the catch block.\n const root = contents && !contents.isEmpty() ? contents.get(0) : undefined;\n if (!root || !isEPackage(root)) {\n console.warn(\n `typemf.ecoreMappings: entry for '${mapping.nsURI}' (${mapping.ecoreFile}) did not load a valid EPackage - skipping.`\n );\n continue;\n }\n runtime.packageRegistry.register(root);\n } catch (err) {\n console.warn(\n `typemf.ecoreMappings: failed to load entry for '${mapping.nsURI}' (${mapping.ecoreFile}): ${(err as Error).message}`\n );\n }\n }\n}\n","/** One entry of the `typemf.ecoreMappings` VS Code setting. */\nexport interface EcoreMappingEntry {\n /** The EPackage nsURI this mapping registers. */\n nsURI: string;\n /** Path to the .ecore file, resolved relative to the first workspace folder. */\n ecoreFile: string;\n}\n\n/**\n * The three per-scope arrays VS Code's own `WorkspaceConfiguration.inspect()` returns for an\n * array-typed setting. Deliberately a plain, local interface - not `vscode`'s own\n * `InspectionResult<T>` type - so this file (and resolveMappings itself) stays usable and\n * unit-testable with no VS Code present at all, matching typemf-runtime.ts/register-defaults.ts.\n */\nexport interface InspectedEcoreMappings {\n globalValue?: EcoreMappingEntry[];\n workspaceValue?: EcoreMappingEntry[];\n workspaceFolderValue?: EcoreMappingEntry[];\n}\n\n/**\n * Merges the three scopes VS Code's own array-typed settings do NOT merge automatically\n * (confirmed directly against VS Code's own documentation: \"Only object value types are merged\n * and all other value types are overridden\" - arrays fall under \"other\"). Uses VS Code's real,\n * general settings precedence - workspaceFolder overrides workspace overrides user (global) - not\n * an invented order.\n *\n * For each nsURI, only the first occurrence (in that precedence order) is kept; every later\n * duplicate - whether from a less-specific scope or a second entry within the very same array -\n * is dropped with a warning rather than silently overwriting or being silently ignored.\n */\nexport function resolveMappings(inspected: InspectedEcoreMappings): EcoreMappingEntry[] {\n const ordered = [\n ...(inspected.workspaceFolderValue ?? []),\n ...(inspected.workspaceValue ?? []),\n ...(inspected.globalValue ?? []),\n ];\n const seen = new Map<string, EcoreMappingEntry>();\n for (const entry of ordered) {\n if (seen.has(entry.nsURI)) {\n console.warn(\n `typemf.ecoreMappings: duplicate entry for nsURI '${entry.nsURI}' - keeping the more specific (or earlier-declared) one, ignoring this one ('${entry.ecoreFile}').`\n );\n continue;\n }\n seen.set(entry.nsURI, entry);\n }\n return [...seen.values()];\n}\n","import { EPackage, isEPackage } from '@typemf/core';\nimport { join } from 'node:path';\nimport type { TypeMfRuntime } from './typemf-runtime.js';\n\n/** One entry of `typemf.modules` in an extension's package.json. */\nexport interface ManifestModuleEntry {\n /** Path to the module's CommonJS bundle, relative to the extension folder. */\n path: string;\n version: string;\n /** Maps each nsURI the module contains to the export holding its EPackage (or a class with a static `eINSTANCE`). */\n packages?: Record<string, string>;\n}\n\n/** The parts of a `vscode.Extension` this file needs. */\nexport interface ExtensionInfo {\n readonly id: string;\n readonly extensionPath: string;\n readonly packageJSON: unknown;\n}\n\n/**\n * Declares every module listed under `typemf.modules` in the extensions' manifests in\n * `runtime.modules`, and registers a descriptor in `runtime.packageRegistry` for each nsURI they\n * contain. `loadFile` loads a module bundle by absolute path. Returns one message per skipped entry.\n */\nexport function registerManifestModules(\n runtime: TypeMfRuntime,\n extensions: readonly ExtensionInfo[],\n loadFile: (absolutePath: string) => unknown\n): string[] {\n const problems: string[] = [];\n for (const extension of extensions) {\n const modules = (extension.packageJSON as { typemf?: { modules?: unknown } } | undefined)?.typemf?.modules;\n if (modules === undefined) continue;\n if (typeof modules !== 'object' || modules === null) {\n problems.push(`${extension.id}: 'typemf.modules' must be an object.`);\n continue;\n }\n for (const [name, raw] of Object.entries(modules)) {\n const entry = raw as Partial<ManifestModuleEntry>;\n if (typeof entry.path !== 'string' || typeof entry.version !== 'string') {\n problems.push(`${extension.id}: module '${name}' needs a string 'path' and 'version'.`);\n continue;\n }\n const absolutePath = join(extension.extensionPath, entry.path);\n try {\n runtime.modules.declare({\n name,\n version: entry.version,\n provider: extension.id,\n load: () => loadFile(absolutePath),\n });\n } catch (err) {\n problems.push(`${extension.id}: ${(err as Error).message}`);\n continue;\n }\n for (const [nsURI, exportName] of Object.entries(entry.packages ?? {})) {\n if (runtime.packageRegistry.containsPackage(nsURI)) {\n problems.push(\n `${extension.id}: nsURI '${nsURI}' of module '${name}' is already registered; keeping the existing registration.`\n );\n continue;\n }\n runtime.packageRegistry.registerDescriptor(nsURI, () =>\n packageFromExport(runtime.modules.require(name, entry.version!), name, exportName)\n );\n }\n }\n }\n return problems;\n}\n\nfunction packageFromExport(module: unknown, moduleName: string, exportName: string): EPackage {\n const exported = (module as Record<string, unknown> | undefined)?.[exportName] as { eINSTANCE?: unknown } | undefined;\n const pkg = exported?.eINSTANCE ?? exported;\n if (!isEPackage(pkg)) {\n throw new Error(\n `Export '${exportName}' of module '${moduleName}' is neither an EPackage nor a class with a static EPackage 'eINSTANCE'.`\n );\n }\n return pkg;\n}\n","import {\n EPackageRegistry,\n EPackageRegistryImpl,\n ResourceFactoryRegistry,\n ResourceFactoryRegistryImpl,\n ResourceSet,\n ResourceSetImpl,\n UriConverterRegistry,\n UriConverterRegistryImpl,\n} from '@typemf/core';\nimport type { TypeMfRuntimeApi } from './api.js';\nimport { ModuleHost } from './module-host.js';\nimport { registerDefaults } from './register-defaults.js';\nimport { registerEcoreMetamodel } from './register-ecore-metamodel.js';\n\nexport interface TypeMfRuntimeOptions {\n /**\n * Whether to register the json/xmi/ecore formats and Ecore's own metamodel. Defaults to true.\n */\n registerDefaults?: boolean;\n}\n\nexport class TypeMfRuntime implements TypeMfRuntimeApi {\n readonly packageRegistry: EPackageRegistry = new EPackageRegistryImpl();\n readonly resourceFactoryRegistry: ResourceFactoryRegistry = new ResourceFactoryRegistryImpl();\n readonly uriConverterRegistry: UriConverterRegistry = new UriConverterRegistryImpl();\n readonly modules = new ModuleHost();\n\n constructor(options: TypeMfRuntimeOptions = {}) {\n if (options.registerDefaults ?? true) {\n registerDefaults(this.resourceFactoryRegistry);\n registerEcoreMetamodel(this.packageRegistry);\n }\n }\n\n createResourceSet(): ResourceSet {\n return new ResourceSetImpl(this.packageRegistry, this.resourceFactoryRegistry, this.uriConverterRegistry);\n }\n\n requireModule(name: string, range: string): unknown {\n return this.modules.require(name, range);\n }\n}\n","import semver from 'semver';\n\n/** A module that an extension declares in its manifest; loaded on its first request. */\nexport interface ModuleDeclaration {\n readonly name: string;\n readonly version: string;\n /** The id of the extension that declares the module. */\n readonly provider: string;\n readonly load: () => unknown;\n}\n\ninterface ModuleEntry {\n readonly version: string;\n readonly provider: string;\n readonly load: () => unknown;\n loaded?: { value: unknown };\n}\n\n/**\n * Holds exactly one instance of every shared module, keyed by npm package name. Modules are either\n * provided as already-loaded objects or declared with a loader that runs on the first request.\n */\nexport class ModuleHost {\n private readonly entries = new Map<string, ModuleEntry>();\n private readonly conflicts = new Map<string, string[]>();\n\n /** Adds an already-loaded module. */\n provide(name: string, version: string, module: unknown, provider = 'typemf.vscode-runtime'): void {\n this.add(name, { version, provider, load: () => module, loaded: { value: module } });\n }\n\n /** Adds a module that is loaded on its first request. */\n declare(declaration: ModuleDeclaration): void {\n if (!semver.valid(declaration.version)) {\n throw new Error(\n `Module '${declaration.name}' from '${declaration.provider}' has an invalid version '${declaration.version}'.`\n );\n }\n this.add(declaration.name, {\n version: declaration.version,\n provider: declaration.provider,\n load: declaration.load,\n });\n }\n\n has(name: string): boolean {\n return this.entries.has(name) || this.conflicts.has(name);\n }\n\n /** The module `name`, if its version satisfies `range`. Throws otherwise. */\n require(name: string, range: string): unknown {\n const providers = this.conflicts.get(name);\n if (providers) {\n throw new Error(\n `Module '${name}' is provided by more than one extension (${providers.join(', ')}); only one provider is allowed.`\n );\n }\n const entry = this.entries.get(name);\n if (!entry) {\n throw new Error(`No installed extension provides module '${name}'.`);\n }\n if (!semver.satisfies(entry.version, range, { includePrerelease: true })) {\n throw new Error(\n `Module '${name}' ${entry.version} (from '${entry.provider}') does not satisfy the requested range '${range}'.`\n );\n }\n if (!entry.loaded) {\n entry.loaded = { value: entry.load() };\n }\n return entry.loaded.value;\n }\n\n private add(name: string, entry: ModuleEntry): void {\n const conflict = this.conflicts.get(name);\n if (conflict) {\n conflict.push(entry.provider);\n return;\n }\n const existing = this.entries.get(name);\n if (existing) {\n this.entries.delete(name);\n this.conflicts.set(name, [existing.provider, entry.provider]);\n return;\n }\n this.entries.set(name, entry);\n }\n}\n","import { ResourceFactoryRegistry } from '@typemf/core';\nimport { registerJsonFormat } from '@typemf/json';\nimport { registerXmiFormat } from '@typemf/xmi';\n\n/**\n * Registers the two formats that are safe in every environment this runtime runs in - the\n * extension host (Node) and a webview (browser), both of which need to work since a shared\n * runtime instance is used from both:\n *\n * - \"json\" (@typemf/json) - JSON.parse/stringify, no environment dependency at all.\n * - \"xmi\" and \"ecore\" (@typemf/xmi) - genuine XML parsing, but @typemf/xmi's own parseXmlDocument\n * feature-detects the native browser DOMParser first and only falls back to a dynamic\n * `import('@xmldom/xmldom')` when that's absent (Node) - confirmed by reading that code\n * directly, not assumed, so this is safe to call unconditionally here.\n *\n * Deliberately does NOT register anything into a UriConverterRegistry, and never will from this\n * function specifically: every concrete UriConverter (e.g. @typemf/node's fs-backed one) is tied\n * to one specific environment, and this function's whole point is to only register things that\n * work everywhere this runtime runs. A Node-only or browser-only converter gets registered by\n * whoever assembles the runtime for that specific environment, not by this shared default.\n *\n * Exported standalone (not just called internally by TypeMfRuntime) so a plain Node script, test,\n * or any other consumer of @typemf/core's ResourceFactoryRegistry can opt into the same defaults\n * without needing @typemf/vscode-runtime or VS Code at all.\n */\nexport function registerDefaults(registry: ResourceFactoryRegistry): void {\n registerJsonFormat(registry);\n registerXmiFormat(registry);\n}\n","import { EcorePackageImpl, EPackageRegistry } from '@typemf/core';\n\n/**\n * Registers Ecore's own metamodel (EClass, EAttribute, EPackage, ...) into `registry` - a\n * deliberate, narrow exception to EPackageRegistry's own \"nothing pre-registered\" design: Ecore\n * itself is foundational, not an arbitrary domain metamodel a dependent extension opts into. Every\n * .ecore file needs it just to be parsed at all, and it's part of the modeling language itself,\n * not something layered on top of it.\n *\n * Without this, opening or creating an instance of Ecore's own classes (e.g. editing a .ecore file\n * directly) had no real path through the \"registered metamodel\" flow at all - it could only ever\n * go through the dynamic .ecore-file picker, loading a fresh, throwaway copy of Ecore's own\n * metamodel each time rather than using the one, real, already-correct EcorePackageImpl.eINSTANCE\n * every generated package already depends on.\n *\n * Exported standalone (not just called internally by TypeMfRuntime), matching register-defaults.ts's\n * own reasoning: a plain Node script, test, or any other consumer of @typemf/core's\n * EPackageRegistry can opt into this without needing @typemf/vscode-runtime or VS Code at all.\n */\nexport function registerEcoreMetamodel(registry: EPackageRegistry): void {\n registry.register(EcorePackageImpl.eINSTANCE);\n}\n","import * as vscode from 'vscode';\nimport type { WorkspaceFileSystem } from './workspace-file-system-uri-converter.js';\n\n/** `vscode.workspace.fs`, adapted to the converter's string-keyed WorkspaceFileSystem. */\nexport const vscodeWorkspaceFileSystem: WorkspaceFileSystem = {\n readFile: (uri) => Promise.resolve(vscode.workspace.fs.readFile(vscode.Uri.parse(uri))),\n async writeFile(uri, content) {\n const target = vscode.Uri.parse(uri);\n await vscode.workspace.fs.createDirectory(vscode.Uri.joinPath(target, '..'));\n await vscode.workspace.fs.writeFile(target, content);\n },\n async exists(uri) {\n try {\n await vscode.workspace.fs.stat(vscode.Uri.parse(uri));\n return true;\n } catch {\n return false;\n }\n },\n};\n","import { URI, UriConverter } from '@typemf/core';\n\n/**\n * The few file-system operations the converter needs, keyed by the document's URI text\n * (`URI.toString()` without its fragment) - what `vscode.workspace.fs` provides, minus the\n * `vscode.Uri` type, so the converter itself stays free of a `vscode` import and unit-testable.\n */\nexport interface WorkspaceFileSystem {\n readFile(uri: string): Promise<Uint8Array>;\n /** Writes `content`, creating the file's missing parent directories first. */\n writeFile(uri: string, content: Uint8Array): Promise<void>;\n exists(uri: string): Promise<boolean>;\n}\n\n/**\n * A UriConverter backed by VS Code's own file system API instead of Node's `fs`, so\n * documents on any registered file system provider - GitHub repositories opened through vscode.dev\n * or \"Remote Repositories\", remote workspaces - open and save like local files. Handles every\n * absolute URI: VS Code reports an unknown scheme as a file system error when it is actually used,\n * and `canHandle` has no way to ask which providers exist.\n */\nexport class WorkspaceFileSystemUriConverter implements UriConverter {\n constructor(private readonly fs: WorkspaceFileSystem) {}\n\n canHandle(uri: URI): boolean {\n return !uri.isRelative();\n }\n\n readBinary(uri: URI): Promise<Uint8Array> {\n return this.fs.readFile(uri.trimFragment().toString());\n }\n\n writeBinary(uri: URI, content: Uint8Array): Promise<void> {\n return this.fs.writeFile(uri.trimFragment().toString(), content);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AAW,IAAI,OAAO,CAAC,cAAc,CAAC,QAAQ,IAAI,UAAU,EAAE,CAAC;AACpF,eAAW,aAAa,MAAO,SAAQ,IAAI,UAAU,EAAE;AACvD,eAAW,WAAW,wBAAwB,SAAS,OAAO,gBAAgB,GAAG;AAC/E,cAAQ,KAAK,mBAAmB,OAAO,EAAE;AAAA,IAC3C;AAAA,EACF;AACA,oBAAkB;AAClB,UAAQ,cAAc,KAAY,mBAAW,YAAY,iBAAiB,CAAC;AAE3E,QAAM,4BAAmC,kBAAU,oBAAoB,CAAC,GAAG,OAAO;AAClF,SAAO;AACT;AAEA,SAAS,iBAAiB,cAA+B;AACvD,aAAO,kCAAc,YAAY,EAAE,YAAY;AACjD;","names":["vscode","import_core","import_node_path","extensions","module","import_core","module","semver","import_core","vscode"]}
|
package/dist/host.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as json from "@typemf/json";
|
|
|
4
4
|
import * as node from "@typemf/node";
|
|
5
5
|
import * as xmi from "@typemf/xmi";
|
|
6
6
|
import { createRequire } from "module";
|
|
7
|
-
import * as
|
|
7
|
+
import * as vscode3 from "vscode";
|
|
8
8
|
|
|
9
9
|
// src/load-ecore-mappings.ts
|
|
10
10
|
import { EcorePackageImpl, isEPackage, URI } from "@typemf/core";
|
|
@@ -47,7 +47,7 @@ async function loadConfiguredEcoreMappings(workspaceFolders, runtime) {
|
|
|
47
47
|
if (!runtime.packageRegistry.containsPackage(EcorePackageImpl.eINSTANCE.getNsURI() ?? "")) {
|
|
48
48
|
runtime.packageRegistry.register(EcorePackageImpl.eINSTANCE);
|
|
49
49
|
}
|
|
50
|
-
if (!runtime.uriConverterRegistry.
|
|
50
|
+
if (!runtime.uriConverterRegistry.getConverter(URI.createFileURI("/"))) {
|
|
51
51
|
runtime.uriConverterRegistry.register(new NodeFileUriConverter());
|
|
52
52
|
}
|
|
53
53
|
const resourceSet = runtime.createResourceSet();
|
|
@@ -234,25 +234,64 @@ var TypeMfRuntime = class {
|
|
|
234
234
|
}
|
|
235
235
|
};
|
|
236
236
|
|
|
237
|
+
// src/vscode-workspace-file-system.ts
|
|
238
|
+
import * as vscode2 from "vscode";
|
|
239
|
+
var vscodeWorkspaceFileSystem = {
|
|
240
|
+
readFile: (uri) => Promise.resolve(vscode2.workspace.fs.readFile(vscode2.Uri.parse(uri))),
|
|
241
|
+
async writeFile(uri, content) {
|
|
242
|
+
const target = vscode2.Uri.parse(uri);
|
|
243
|
+
await vscode2.workspace.fs.createDirectory(vscode2.Uri.joinPath(target, ".."));
|
|
244
|
+
await vscode2.workspace.fs.writeFile(target, content);
|
|
245
|
+
},
|
|
246
|
+
async exists(uri) {
|
|
247
|
+
try {
|
|
248
|
+
await vscode2.workspace.fs.stat(vscode2.Uri.parse(uri));
|
|
249
|
+
return true;
|
|
250
|
+
} catch {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// src/workspace-file-system-uri-converter.ts
|
|
257
|
+
var WorkspaceFileSystemUriConverter = class {
|
|
258
|
+
constructor(fs) {
|
|
259
|
+
this.fs = fs;
|
|
260
|
+
}
|
|
261
|
+
fs;
|
|
262
|
+
canHandle(uri) {
|
|
263
|
+
return !uri.isRelative();
|
|
264
|
+
}
|
|
265
|
+
readBinary(uri) {
|
|
266
|
+
return this.fs.readFile(uri.trimFragment().toString());
|
|
267
|
+
}
|
|
268
|
+
writeBinary(uri, content) {
|
|
269
|
+
return this.fs.writeFile(uri.trimFragment().toString(), content);
|
|
270
|
+
}
|
|
271
|
+
exists(uri) {
|
|
272
|
+
return this.fs.exists(uri.trimFragment().toString());
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
|
|
237
276
|
// src/activate-runtime.ts
|
|
238
277
|
async function activateRuntime(context, versions) {
|
|
239
278
|
const runtime = new TypeMfRuntime();
|
|
240
|
-
runtime.uriConverterRegistry.register(new
|
|
279
|
+
runtime.uriConverterRegistry.register(new WorkspaceFileSystemUriConverter(vscodeWorkspaceFileSystem));
|
|
241
280
|
runtime.modules.provide("@typemf/core", versions["@typemf/core"], core);
|
|
242
281
|
runtime.modules.provide("@typemf/json", versions["@typemf/json"], json);
|
|
243
282
|
runtime.modules.provide("@typemf/node", versions["@typemf/node"], node);
|
|
244
283
|
runtime.modules.provide("@typemf/xmi", versions["@typemf/xmi"], xmi);
|
|
245
284
|
const scanned = /* @__PURE__ */ new Set();
|
|
246
285
|
const scanNewExtensions = () => {
|
|
247
|
-
const added =
|
|
286
|
+
const added = vscode3.extensions.all.filter((extension) => !scanned.has(extension.id));
|
|
248
287
|
for (const extension of added) scanned.add(extension.id);
|
|
249
288
|
for (const problem of registerManifestModules(runtime, added, loadCommonJsFile)) {
|
|
250
289
|
console.warn(`TypeMF runtime: ${problem}`);
|
|
251
290
|
}
|
|
252
291
|
};
|
|
253
292
|
scanNewExtensions();
|
|
254
|
-
context.subscriptions.push(
|
|
255
|
-
await loadConfiguredEcoreMappings(
|
|
293
|
+
context.subscriptions.push(vscode3.extensions.onDidChange(scanNewExtensions));
|
|
294
|
+
await loadConfiguredEcoreMappings(vscode3.workspace.workspaceFolders ?? [], runtime);
|
|
256
295
|
return runtime;
|
|
257
296
|
}
|
|
258
297
|
function loadCommonJsFile(absolutePath) {
|
package/dist/host.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/activate-runtime.ts","../src/load-ecore-mappings.ts","../src/ecore-mappings.ts","../src/manifest-modules.ts","../src/typemf-runtime.ts","../src/module-host.ts","../src/register-defaults.ts","../src/register-ecore-metamodel.ts"],"sourcesContent":["import * as core from '@typemf/core';\nimport * as json from '@typemf/json';\nimport * as node from '@typemf/node';\nimport * as xmi from '@typemf/xmi';\nimport { createRequire } from 'node:module';\nimport * as vscode from 'vscode';\nimport { loadConfiguredEcoreMappings } from './load-ecore-mappings.js';\nimport { registerManifestModules } from './manifest-modules.js';\nimport type { TypeMfRuntimeApi } from './api.js';\nimport { TypeMfRuntime } from './typemf-runtime.js';\n\n/** Versions of the TypeMF libraries bundled into the runtime extension. */\nexport interface BuiltinModuleVersions {\n '@typemf/core': string;\n '@typemf/json': string;\n '@typemf/node': string;\n '@typemf/xmi': string;\n}\n\n/**\n * Creates the shared runtime: provides the bundled TypeMF libraries as shared modules, declares\n * the modules of all installed extensions (and of extensions installed later), and loads the\n * `typemf.ecoreMappings` setting. Called by the runtime extension's `activate()`.\n */\nexport async function activateRuntime(\n context: vscode.ExtensionContext,\n versions: BuiltinModuleVersions\n): Promise<TypeMfRuntimeApi> {\n const runtime = new TypeMfRuntime();\n runtime.uriConverterRegistry.register(new node.NodeFileUriConverter());\n runtime.modules.provide('@typemf/core', versions['@typemf/core'], core);\n runtime.modules.provide('@typemf/json', versions['@typemf/json'], json);\n runtime.modules.provide('@typemf/node', versions['@typemf/node'], node);\n runtime.modules.provide('@typemf/xmi', versions['@typemf/xmi'], xmi);\n\n const scanned = new Set<string>();\n const scanNewExtensions = () => {\n const added = vscode.extensions.all.filter((extension) => !scanned.has(extension.id));\n for (const extension of added) scanned.add(extension.id);\n for (const problem of registerManifestModules(runtime, added, loadCommonJsFile)) {\n console.warn(`TypeMF runtime: ${problem}`);\n }\n };\n scanNewExtensions();\n context.subscriptions.push(vscode.extensions.onDidChange(scanNewExtensions));\n\n await loadConfiguredEcoreMappings(vscode.workspace.workspaceFolders ?? [], runtime);\n return runtime;\n}\n\nfunction loadCommonJsFile(absolutePath: string): unknown {\n return createRequire(absolutePath)(absolutePath);\n}\n","import { EcorePackageImpl, isEPackage, URI } from '@typemf/core';\nimport { NodeFileUriConverter } from '@typemf/node';\nimport { join } from 'node:path';\nimport * as vscode from 'vscode';\nimport { EcoreMappingEntry, resolveMappings } from './ecore-mappings.js';\nimport type { TypeMfRuntimeApi } from './api.js';\n\n/**\n * Reads the `typemf.ecoreMappings` setting (merged across scopes, see resolveMappings), loads\n * each entry's .ecore file, and registers its root EPackage into `runtime.packageRegistry`.\n *\n * A real `vscode` value import, unlike typemf-runtime.ts/register-defaults.ts/ecore-mappings.ts -\n * this genuinely needs vscode.workspace.getConfiguration() and real filesystem access, so it's\n * kept in its own file rather than folded into those, the same reasoning extension.ts's own\n * `import type` split was built around.\n */\nexport async function loadConfiguredEcoreMappings(\n workspaceFolders: readonly vscode.WorkspaceFolder[],\n runtime: TypeMfRuntimeApi\n): Promise<void> {\n const firstFolder = workspaceFolders[0];\n\n // getConfiguration's second argument is what makes workspaceFolderValue resolve to the RIGHT\n // folder's own settings in a multi-root workspace - and \"always resolve relative paths against\n // the first workspace folder\" (decided earlier) means that's also the one folder whose\n // workspaceFolderValue is relevant here, not any other folder's.\n const inspected = vscode.workspace\n .getConfiguration('typemf', firstFolder?.uri)\n .inspect<EcoreMappingEntry[]>('ecoreMappings');\n const mappings = resolveMappings(inspected ?? {});\n if (mappings.length === 0) return;\n\n if (!firstFolder) {\n console.warn(\n `typemf.ecoreMappings: ${mappings.length} entr${mappings.length === 1 ? 'y' : 'ies'} configured, but no workspace folder is open to resolve relative paths against - skipping.`\n );\n return;\n }\n\n // Ecore's own metamodel must be registered before any .ecore file's xsi:type=\"ecore:EClass\"\n // etc. can be interpreted at all - always safe and correct to register unconditionally, since\n // Ecore's own nsURI (http://www.eclipse.org/emf/2002/Ecore) never collides with a real domain\n // metamodel's, and it's always live once @typemf/core is loaded regardless (the self-hosted\n // swap made that permanent - see @typemf/generator's NOTES.md).\n if (!runtime.packageRegistry.containsPackage(EcorePackageImpl.eINSTANCE.getNsURI() ?? '')) {\n runtime.packageRegistry.register(EcorePackageImpl.eINSTANCE);\n }\n\n // A file:// converter is needed to actually read .ecore files from disk. The extension host\n // (unlike a webview) is always Node-capable, so registering this into the SHARED\n // uriConverterRegistry - not a separate, throwaway one just for this loading step - is safe,\n // and lets every other extension sharing this runtime benefit from file:// support too, not\n // just this one loading pass.\n if (!runtime.uriConverterRegistry.getConverters().some((converter) => converter instanceof NodeFileUriConverter)) {\n runtime.uriConverterRegistry.register(new NodeFileUriConverter());\n }\n\n const resourceSet = runtime.createResourceSet();\n\n for (const mapping of mappings) {\n try {\n const absolutePath = join(firstFolder.uri.fsPath, mapping.ecoreFile);\n const resource = await resourceSet.getResource(URI.createFileURI(absolutePath), true);\n const contents = resource?.getContents();\n // EList.get(0) throws on an empty list rather than returning undefined - check isEmpty()\n // first so a load that produced no root reports the clear message below, not a confusing\n // \"index out of bounds\" one from the catch block.\n const root = contents && !contents.isEmpty() ? contents.get(0) : undefined;\n if (!root || !isEPackage(root)) {\n console.warn(\n `typemf.ecoreMappings: entry for '${mapping.nsURI}' (${mapping.ecoreFile}) did not load a valid EPackage - skipping.`\n );\n continue;\n }\n runtime.packageRegistry.register(root);\n } catch (err) {\n console.warn(\n `typemf.ecoreMappings: failed to load entry for '${mapping.nsURI}' (${mapping.ecoreFile}): ${(err as Error).message}`\n );\n }\n }\n}\n","/** One entry of the `typemf.ecoreMappings` VS Code setting. */\nexport interface EcoreMappingEntry {\n /** The EPackage nsURI this mapping registers. */\n nsURI: string;\n /** Path to the .ecore file, resolved relative to the first workspace folder. */\n ecoreFile: string;\n}\n\n/**\n * The three per-scope arrays VS Code's own `WorkspaceConfiguration.inspect()` returns for an\n * array-typed setting. Deliberately a plain, local interface - not `vscode`'s own\n * `InspectionResult<T>` type - so this file (and resolveMappings itself) stays usable and\n * unit-testable with no VS Code present at all, matching typemf-runtime.ts/register-defaults.ts.\n */\nexport interface InspectedEcoreMappings {\n globalValue?: EcoreMappingEntry[];\n workspaceValue?: EcoreMappingEntry[];\n workspaceFolderValue?: EcoreMappingEntry[];\n}\n\n/**\n * Merges the three scopes VS Code's own array-typed settings do NOT merge automatically\n * (confirmed directly against VS Code's own documentation: \"Only object value types are merged\n * and all other value types are overridden\" - arrays fall under \"other\"). Uses VS Code's real,\n * general settings precedence - workspaceFolder overrides workspace overrides user (global) - not\n * an invented order.\n *\n * For each nsURI, only the first occurrence (in that precedence order) is kept; every later\n * duplicate - whether from a less-specific scope or a second entry within the very same array -\n * is dropped with a warning rather than silently overwriting or being silently ignored.\n */\nexport function resolveMappings(inspected: InspectedEcoreMappings): EcoreMappingEntry[] {\n const ordered = [\n ...(inspected.workspaceFolderValue ?? []),\n ...(inspected.workspaceValue ?? []),\n ...(inspected.globalValue ?? []),\n ];\n const seen = new Map<string, EcoreMappingEntry>();\n for (const entry of ordered) {\n if (seen.has(entry.nsURI)) {\n console.warn(\n `typemf.ecoreMappings: duplicate entry for nsURI '${entry.nsURI}' - keeping the more specific (or earlier-declared) one, ignoring this one ('${entry.ecoreFile}').`\n );\n continue;\n }\n seen.set(entry.nsURI, entry);\n }\n return [...seen.values()];\n}\n","import { EPackage, isEPackage } from '@typemf/core';\nimport { join } from 'node:path';\nimport type { TypeMfRuntime } from './typemf-runtime.js';\n\n/** One entry of `typemf.modules` in an extension's package.json. */\nexport interface ManifestModuleEntry {\n /** Path to the module's CommonJS bundle, relative to the extension folder. */\n path: string;\n version: string;\n /** Maps each nsURI the module contains to the export holding its EPackage (or a class with a static `eINSTANCE`). */\n packages?: Record<string, string>;\n}\n\n/** The parts of a `vscode.Extension` this file needs. */\nexport interface ExtensionInfo {\n readonly id: string;\n readonly extensionPath: string;\n readonly packageJSON: unknown;\n}\n\n/**\n * Declares every module listed under `typemf.modules` in the extensions' manifests in\n * `runtime.modules`, and registers a descriptor in `runtime.packageRegistry` for each nsURI they\n * contain. `loadFile` loads a module bundle by absolute path. Returns one message per skipped entry.\n */\nexport function registerManifestModules(\n runtime: TypeMfRuntime,\n extensions: readonly ExtensionInfo[],\n loadFile: (absolutePath: string) => unknown\n): string[] {\n const problems: string[] = [];\n for (const extension of extensions) {\n const modules = (extension.packageJSON as { typemf?: { modules?: unknown } } | undefined)?.typemf?.modules;\n if (modules === undefined) continue;\n if (typeof modules !== 'object' || modules === null) {\n problems.push(`${extension.id}: 'typemf.modules' must be an object.`);\n continue;\n }\n for (const [name, raw] of Object.entries(modules)) {\n const entry = raw as Partial<ManifestModuleEntry>;\n if (typeof entry.path !== 'string' || typeof entry.version !== 'string') {\n problems.push(`${extension.id}: module '${name}' needs a string 'path' and 'version'.`);\n continue;\n }\n const absolutePath = join(extension.extensionPath, entry.path);\n try {\n runtime.modules.declare({\n name,\n version: entry.version,\n provider: extension.id,\n load: () => loadFile(absolutePath),\n });\n } catch (err) {\n problems.push(`${extension.id}: ${(err as Error).message}`);\n continue;\n }\n for (const [nsURI, exportName] of Object.entries(entry.packages ?? {})) {\n if (runtime.packageRegistry.containsPackage(nsURI)) {\n problems.push(\n `${extension.id}: nsURI '${nsURI}' of module '${name}' is already registered; keeping the existing registration.`\n );\n continue;\n }\n runtime.packageRegistry.registerDescriptor(nsURI, () =>\n packageFromExport(runtime.modules.require(name, entry.version!), name, exportName)\n );\n }\n }\n }\n return problems;\n}\n\nfunction packageFromExport(module: unknown, moduleName: string, exportName: string): EPackage {\n const exported = (module as Record<string, unknown> | undefined)?.[exportName] as { eINSTANCE?: unknown } | undefined;\n const pkg = exported?.eINSTANCE ?? exported;\n if (!isEPackage(pkg)) {\n throw new Error(\n `Export '${exportName}' of module '${moduleName}' is neither an EPackage nor a class with a static EPackage 'eINSTANCE'.`\n );\n }\n return pkg;\n}\n","import {\n EPackageRegistry,\n EPackageRegistryImpl,\n ResourceFactoryRegistry,\n ResourceFactoryRegistryImpl,\n ResourceSet,\n ResourceSetImpl,\n UriConverterRegistry,\n UriConverterRegistryImpl,\n} from '@typemf/core';\nimport type { TypeMfRuntimeApi } from './api.js';\nimport { ModuleHost } from './module-host.js';\nimport { registerDefaults } from './register-defaults.js';\nimport { registerEcoreMetamodel } from './register-ecore-metamodel.js';\n\nexport interface TypeMfRuntimeOptions {\n /**\n * Whether to register the json/xmi/ecore formats and Ecore's own metamodel. Defaults to true.\n */\n registerDefaults?: boolean;\n}\n\nexport class TypeMfRuntime implements TypeMfRuntimeApi {\n readonly packageRegistry: EPackageRegistry = new EPackageRegistryImpl();\n readonly resourceFactoryRegistry: ResourceFactoryRegistry = new ResourceFactoryRegistryImpl();\n readonly uriConverterRegistry: UriConverterRegistry = new UriConverterRegistryImpl();\n readonly modules = new ModuleHost();\n\n constructor(options: TypeMfRuntimeOptions = {}) {\n if (options.registerDefaults ?? true) {\n registerDefaults(this.resourceFactoryRegistry);\n registerEcoreMetamodel(this.packageRegistry);\n }\n }\n\n createResourceSet(): ResourceSet {\n return new ResourceSetImpl(this.packageRegistry, this.resourceFactoryRegistry, this.uriConverterRegistry);\n }\n\n requireModule(name: string, range: string): unknown {\n return this.modules.require(name, range);\n }\n}\n","import semver from 'semver';\n\n/** A module that an extension declares in its manifest; loaded on its first request. */\nexport interface ModuleDeclaration {\n readonly name: string;\n readonly version: string;\n /** The id of the extension that declares the module. */\n readonly provider: string;\n readonly load: () => unknown;\n}\n\ninterface ModuleEntry {\n readonly version: string;\n readonly provider: string;\n readonly load: () => unknown;\n loaded?: { value: unknown };\n}\n\n/**\n * Holds exactly one instance of every shared module, keyed by npm package name. Modules are either\n * provided as already-loaded objects or declared with a loader that runs on the first request.\n */\nexport class ModuleHost {\n private readonly entries = new Map<string, ModuleEntry>();\n private readonly conflicts = new Map<string, string[]>();\n\n /** Adds an already-loaded module. */\n provide(name: string, version: string, module: unknown, provider = 'typemf.vscode-runtime'): void {\n this.add(name, { version, provider, load: () => module, loaded: { value: module } });\n }\n\n /** Adds a module that is loaded on its first request. */\n declare(declaration: ModuleDeclaration): void {\n if (!semver.valid(declaration.version)) {\n throw new Error(\n `Module '${declaration.name}' from '${declaration.provider}' has an invalid version '${declaration.version}'.`\n );\n }\n this.add(declaration.name, {\n version: declaration.version,\n provider: declaration.provider,\n load: declaration.load,\n });\n }\n\n has(name: string): boolean {\n return this.entries.has(name) || this.conflicts.has(name);\n }\n\n /** The module `name`, if its version satisfies `range`. Throws otherwise. */\n require(name: string, range: string): unknown {\n const providers = this.conflicts.get(name);\n if (providers) {\n throw new Error(\n `Module '${name}' is provided by more than one extension (${providers.join(', ')}); only one provider is allowed.`\n );\n }\n const entry = this.entries.get(name);\n if (!entry) {\n throw new Error(`No installed extension provides module '${name}'.`);\n }\n if (!semver.satisfies(entry.version, range, { includePrerelease: true })) {\n throw new Error(\n `Module '${name}' ${entry.version} (from '${entry.provider}') does not satisfy the requested range '${range}'.`\n );\n }\n if (!entry.loaded) {\n entry.loaded = { value: entry.load() };\n }\n return entry.loaded.value;\n }\n\n private add(name: string, entry: ModuleEntry): void {\n const conflict = this.conflicts.get(name);\n if (conflict) {\n conflict.push(entry.provider);\n return;\n }\n const existing = this.entries.get(name);\n if (existing) {\n this.entries.delete(name);\n this.conflicts.set(name, [existing.provider, entry.provider]);\n return;\n }\n this.entries.set(name, entry);\n }\n}\n","import { ResourceFactoryRegistry } from '@typemf/core';\nimport { registerJsonFormat } from '@typemf/json';\nimport { registerXmiFormat } from '@typemf/xmi';\n\n/**\n * Registers the two formats that are safe in every environment this runtime runs in - the\n * extension host (Node) and a webview (browser), both of which need to work since a shared\n * runtime instance is used from both:\n *\n * - \"json\" (@typemf/json) - JSON.parse/stringify, no environment dependency at all.\n * - \"xmi\" and \"ecore\" (@typemf/xmi) - genuine XML parsing, but @typemf/xmi's own parseXmlDocument\n * feature-detects the native browser DOMParser first and only falls back to a dynamic\n * `import('@xmldom/xmldom')` when that's absent (Node) - confirmed by reading that code\n * directly, not assumed, so this is safe to call unconditionally here.\n *\n * Deliberately does NOT register anything into a UriConverterRegistry, and never will from this\n * function specifically: every concrete UriConverter (e.g. @typemf/node's fs-backed one) is tied\n * to one specific environment, and this function's whole point is to only register things that\n * work everywhere this runtime runs. A Node-only or browser-only converter gets registered by\n * whoever assembles the runtime for that specific environment, not by this shared default.\n *\n * Exported standalone (not just called internally by TypeMfRuntime) so a plain Node script, test,\n * or any other consumer of @typemf/core's ResourceFactoryRegistry can opt into the same defaults\n * without needing @typemf/vscode-runtime or VS Code at all.\n */\nexport function registerDefaults(registry: ResourceFactoryRegistry): void {\n registerJsonFormat(registry);\n registerXmiFormat(registry);\n}\n","import { EcorePackageImpl, EPackageRegistry } from '@typemf/core';\n\n/**\n * Registers Ecore's own metamodel (EClass, EAttribute, EPackage, ...) into `registry` - a\n * deliberate, narrow exception to EPackageRegistry's own \"nothing pre-registered\" design: Ecore\n * itself is foundational, not an arbitrary domain metamodel a dependent extension opts into. Every\n * .ecore file needs it just to be parsed at all, and it's part of the modeling language itself,\n * not something layered on top of it.\n *\n * Without this, opening or creating an instance of Ecore's own classes (e.g. editing a .ecore file\n * directly) had no real path through the \"registered metamodel\" flow at all - it could only ever\n * go through the dynamic .ecore-file picker, loading a fresh, throwaway copy of Ecore's own\n * metamodel each time rather than using the one, real, already-correct EcorePackageImpl.eINSTANCE\n * every generated package already depends on.\n *\n * Exported standalone (not just called internally by TypeMfRuntime), matching register-defaults.ts's\n * own reasoning: a plain Node script, test, or any other consumer of @typemf/core's\n * EPackageRegistry can opt into this without needing @typemf/vscode-runtime or VS Code at all.\n */\nexport function registerEcoreMetamodel(registry: EPackageRegistry): void {\n registry.register(EcorePackageImpl.eINSTANCE);\n}\n"],"mappings":";AAAA,YAAY,UAAU;AACtB,YAAY,UAAU;AACtB,YAAY,UAAU;AACtB,YAAY,SAAS;AACrB,SAAS,qBAAqB;AAC9B,YAAYA,aAAY;;;ACLxB,SAAS,kBAAkB,YAAY,WAAW;AAClD,SAAS,4BAA4B;AACrC,SAAS,YAAY;AACrB,YAAY,YAAY;;;AC4BjB,SAAS,gBAAgB,WAAwD;AACtF,QAAM,UAAU;AAAA,IACd,GAAI,UAAU,wBAAwB,CAAC;AAAA,IACvC,GAAI,UAAU,kBAAkB,CAAC;AAAA,IACjC,GAAI,UAAU,eAAe,CAAC;AAAA,EAChC;AACA,QAAM,OAAO,oBAAI,IAA+B;AAChD,aAAW,SAAS,SAAS;AAC3B,QAAI,KAAK,IAAI,MAAM,KAAK,GAAG;AACzB,cAAQ;AAAA,QACN,oDAAoD,MAAM,KAAK,gFAAgF,MAAM,SAAS;AAAA,MAChK;AACA;AAAA,IACF;AACA,SAAK,IAAI,MAAM,OAAO,KAAK;AAAA,EAC7B;AACA,SAAO,CA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YAAY;AACjD;","names":["vscode","isEPackage","join","extensions","EcorePackageImpl"]}
|
|
1
|
+
{"version":3,"sources":["../src/activate-runtime.ts","../src/load-ecore-mappings.ts","../src/ecore-mappings.ts","../src/manifest-modules.ts","../src/typemf-runtime.ts","../src/module-host.ts","../src/register-defaults.ts","../src/register-ecore-metamodel.ts","../src/vscode-workspace-file-system.ts","../src/workspace-file-system-uri-converter.ts"],"sourcesContent":["import * as core from '@typemf/core';\nimport * as json from '@typemf/json';\nimport * as node from '@typemf/node';\nimport * as xmi from '@typemf/xmi';\nimport { createRequire } from 'node:module';\nimport * as vscode from 'vscode';\nimport { loadConfiguredEcoreMappings } from './load-ecore-mappings.js';\nimport { registerManifestModules } from './manifest-modules.js';\nimport type { TypeMfRuntimeApi } from './api.js';\nimport { TypeMfRuntime } from './typemf-runtime.js';\nimport { vscodeWorkspaceFileSystem } from './vscode-workspace-file-system.js';\nimport { WorkspaceFileSystemUriConverter } from './workspace-file-system-uri-converter.js';\n\n/** Versions of the TypeMF libraries bundled into the runtime extension. */\nexport interface BuiltinModuleVersions {\n '@typemf/core': string;\n '@typemf/json': string;\n '@typemf/node': string;\n '@typemf/xmi': string;\n}\n\n/**\n * Creates the shared runtime: provides the bundled TypeMF libraries as shared modules, declares\n * the modules of all installed extensions (and of extensions installed later), and loads the\n * `typemf.ecoreMappings` setting. Called by the runtime extension's `activate()`.\n */\nexport async function activateRuntime(\n context: vscode.ExtensionContext,\n versions: BuiltinModuleVersions\n): Promise<TypeMfRuntimeApi> {\n const runtime = new TypeMfRuntime();\n runtime.uriConverterRegistry.register(new WorkspaceFileSystemUriConverter(vscodeWorkspaceFileSystem));\n runtime.modules.provide('@typemf/core', versions['@typemf/core'], core);\n runtime.modules.provide('@typemf/json', versions['@typemf/json'], json);\n runtime.modules.provide('@typemf/node', versions['@typemf/node'], node);\n runtime.modules.provide('@typemf/xmi', versions['@typemf/xmi'], xmi);\n\n const scanned = new Set<string>();\n const scanNewExtensions = () => {\n const added = vscode.extensions.all.filter((extension) => !scanned.has(extension.id));\n for (const extension of added) scanned.add(extension.id);\n for (const problem of registerManifestModules(runtime, added, loadCommonJsFile)) {\n console.warn(`TypeMF runtime: ${problem}`);\n }\n };\n scanNewExtensions();\n context.subscriptions.push(vscode.extensions.onDidChange(scanNewExtensions));\n\n await loadConfiguredEcoreMappings(vscode.workspace.workspaceFolders ?? [], runtime);\n return runtime;\n}\n\nfunction loadCommonJsFile(absolutePath: string): unknown {\n return createRequire(absolutePath)(absolutePath);\n}\n","import { EcorePackageImpl, isEPackage, URI } from '@typemf/core';\nimport { NodeFileUriConverter } from '@typemf/node';\nimport { join } from 'node:path';\nimport * as vscode from 'vscode';\nimport { EcoreMappingEntry, resolveMappings } from './ecore-mappings.js';\nimport type { TypeMfRuntimeApi } from './api.js';\n\n/**\n * Reads the `typemf.ecoreMappings` setting (merged across scopes, see resolveMappings), loads\n * each entry's .ecore file, and registers its root EPackage into `runtime.packageRegistry`.\n *\n * A real `vscode` value import, unlike typemf-runtime.ts/register-defaults.ts/ecore-mappings.ts -\n * this genuinely needs vscode.workspace.getConfiguration() and real filesystem access, so it's\n * kept in its own file rather than folded into those, the same reasoning extension.ts's own\n * `import type` split was built around.\n */\nexport async function loadConfiguredEcoreMappings(\n workspaceFolders: readonly vscode.WorkspaceFolder[],\n runtime: TypeMfRuntimeApi\n): Promise<void> {\n const firstFolder = workspaceFolders[0];\n\n // getConfiguration's second argument is what makes workspaceFolderValue resolve to the RIGHT\n // folder's own settings in a multi-root workspace - and \"always resolve relative paths against\n // the first workspace folder\" (decided earlier) means that's also the one folder whose\n // workspaceFolderValue is relevant here, not any other folder's.\n const inspected = vscode.workspace\n .getConfiguration('typemf', firstFolder?.uri)\n .inspect<EcoreMappingEntry[]>('ecoreMappings');\n const mappings = resolveMappings(inspected ?? {});\n if (mappings.length === 0) return;\n\n if (!firstFolder) {\n console.warn(\n `typemf.ecoreMappings: ${mappings.length} entr${mappings.length === 1 ? 'y' : 'ies'} configured, but no workspace folder is open to resolve relative paths against - skipping.`\n );\n return;\n }\n\n // Ecore's own metamodel must be registered before any .ecore file's xsi:type=\"ecore:EClass\"\n // etc. can be interpreted at all - always safe and correct to register unconditionally, since\n // Ecore's own nsURI (http://www.eclipse.org/emf/2002/Ecore) never collides with a real domain\n // metamodel's, and it's always live once @typemf/core is loaded regardless (the self-hosted\n // swap made that permanent - see @typemf/generator's NOTES.md).\n if (!runtime.packageRegistry.containsPackage(EcorePackageImpl.eINSTANCE.getNsURI() ?? '')) {\n runtime.packageRegistry.register(EcorePackageImpl.eINSTANCE);\n }\n\n // A file:// converter is needed to actually read .ecore files from disk - normally already\n // registered by activateRuntime (the workspace file system one); this is the fallback when\n // nothing handles file:// yet. The extension host (unlike a webview) is always Node-capable, so\n // registering it into the SHARED uriConverterRegistry - not a separate, throwaway one just for\n // this loading step - is safe, and lets every other extension sharing this runtime benefit from\n // file:// support too, not just this one loading pass.\n if (!runtime.uriConverterRegistry.getConverter(URI.createFileURI('/'))) {\n runtime.uriConverterRegistry.register(new NodeFileUriConverter());\n }\n\n const resourceSet = runtime.createResourceSet();\n\n for (const mapping of mappings) {\n try {\n const absolutePath = join(firstFolder.uri.fsPath, mapping.ecoreFile);\n const resource = await resourceSet.getResource(URI.createFileURI(absolutePath), true);\n const contents = resource?.getContents();\n // EList.get(0) throws on an empty list rather than returning undefined - check isEmpty()\n // first so a load that produced no root reports the clear message below, not a confusing\n // \"index out of bounds\" one from the catch block.\n const root = contents && !contents.isEmpty() ? contents.get(0) : undefined;\n if (!root || !isEPackage(root)) {\n console.warn(\n `typemf.ecoreMappings: entry for '${mapping.nsURI}' (${mapping.ecoreFile}) did not load a valid EPackage - skipping.`\n );\n continue;\n }\n runtime.packageRegistry.register(root);\n } catch (err) {\n console.warn(\n `typemf.ecoreMappings: failed to load entry for '${mapping.nsURI}' (${mapping.ecoreFile}): ${(err as Error).message}`\n );\n }\n }\n}\n","/** One entry of the `typemf.ecoreMappings` VS Code setting. */\nexport interface EcoreMappingEntry {\n /** The EPackage nsURI this mapping registers. */\n nsURI: string;\n /** Path to the .ecore file, resolved relative to the first workspace folder. */\n ecoreFile: string;\n}\n\n/**\n * The three per-scope arrays VS Code's own `WorkspaceConfiguration.inspect()` returns for an\n * array-typed setting. Deliberately a plain, local interface - not `vscode`'s own\n * `InspectionResult<T>` type - so this file (and resolveMappings itself) stays usable and\n * unit-testable with no VS Code present at all, matching typemf-runtime.ts/register-defaults.ts.\n */\nexport interface InspectedEcoreMappings {\n globalValue?: EcoreMappingEntry[];\n workspaceValue?: EcoreMappingEntry[];\n workspaceFolderValue?: EcoreMappingEntry[];\n}\n\n/**\n * Merges the three scopes VS Code's own array-typed settings do NOT merge automatically\n * (confirmed directly against VS Code's own documentation: \"Only object value types are merged\n * and all other value types are overridden\" - arrays fall under \"other\"). Uses VS Code's real,\n * general settings precedence - workspaceFolder overrides workspace overrides user (global) - not\n * an invented order.\n *\n * For each nsURI, only the first occurrence (in that precedence order) is kept; every later\n * duplicate - whether from a less-specific scope or a second entry within the very same array -\n * is dropped with a warning rather than silently overwriting or being silently ignored.\n */\nexport function resolveMappings(inspected: InspectedEcoreMappings): EcoreMappingEntry[] {\n const ordered = [\n ...(inspected.workspaceFolderValue ?? []),\n ...(inspected.workspaceValue ?? []),\n ...(inspected.globalValue ?? []),\n ];\n const seen = new Map<string, EcoreMappingEntry>();\n for (const entry of ordered) {\n if (seen.has(entry.nsURI)) {\n console.warn(\n `typemf.ecoreMappings: duplicate entry for nsURI '${entry.nsURI}' - keeping the more specific (or earlier-declared) one, ignoring this one ('${entry.ecoreFile}').`\n );\n continue;\n }\n seen.set(entry.nsURI, entry);\n }\n return [...seen.values()];\n}\n","import { EPackage, isEPackage } from '@typemf/core';\nimport { join } from 'node:path';\nimport type { TypeMfRuntime } from './typemf-runtime.js';\n\n/** One entry of `typemf.modules` in an extension's package.json. */\nexport interface ManifestModuleEntry {\n /** Path to the module's CommonJS bundle, relative to the extension folder. */\n path: string;\n version: string;\n /** Maps each nsURI the module contains to the export holding its EPackage (or a class with a static `eINSTANCE`). */\n packages?: Record<string, string>;\n}\n\n/** The parts of a `vscode.Extension` this file needs. */\nexport interface ExtensionInfo {\n readonly id: string;\n readonly extensionPath: string;\n readonly packageJSON: unknown;\n}\n\n/**\n * Declares every module listed under `typemf.modules` in the extensions' manifests in\n * `runtime.modules`, and registers a descriptor in `runtime.packageRegistry` for each nsURI they\n * contain. `loadFile` loads a module bundle by absolute path. Returns one message per skipped entry.\n */\nexport function registerManifestModules(\n runtime: TypeMfRuntime,\n extensions: readonly ExtensionInfo[],\n loadFile: (absolutePath: string) => unknown\n): string[] {\n const problems: string[] = [];\n for (const extension of extensions) {\n const modules = (extension.packageJSON as { typemf?: { modules?: unknown } } | undefined)?.typemf?.modules;\n if (modules === undefined) continue;\n if (typeof modules !== 'object' || modules === null) {\n problems.push(`${extension.id}: 'typemf.modules' must be an object.`);\n continue;\n }\n for (const [name, raw] of Object.entries(modules)) {\n const entry = raw as Partial<ManifestModuleEntry>;\n if (typeof entry.path !== 'string' || typeof entry.version !== 'string') {\n problems.push(`${extension.id}: module '${name}' needs a string 'path' and 'version'.`);\n continue;\n }\n const absolutePath = join(extension.extensionPath, entry.path);\n try {\n runtime.modules.declare({\n name,\n version: entry.version,\n provider: extension.id,\n load: () => loadFile(absolutePath),\n });\n } catch (err) {\n problems.push(`${extension.id}: ${(err as Error).message}`);\n continue;\n }\n for (const [nsURI, exportName] of Object.entries(entry.packages ?? {})) {\n if (runtime.packageRegistry.containsPackage(nsURI)) {\n problems.push(\n `${extension.id}: nsURI '${nsURI}' of module '${name}' is already registered; keeping the existing registration.`\n );\n continue;\n }\n runtime.packageRegistry.registerDescriptor(nsURI, () =>\n packageFromExport(runtime.modules.require(name, entry.version!), name, exportName)\n );\n }\n }\n }\n return problems;\n}\n\nfunction packageFromExport(module: unknown, moduleName: string, exportName: string): EPackage {\n const exported = (module as Record<string, unknown> | undefined)?.[exportName] as { eINSTANCE?: unknown } | undefined;\n const pkg = exported?.eINSTANCE ?? exported;\n if (!isEPackage(pkg)) {\n throw new Error(\n `Export '${exportName}' of module '${moduleName}' is neither an EPackage nor a class with a static EPackage 'eINSTANCE'.`\n );\n }\n return pkg;\n}\n","import {\n EPackageRegistry,\n EPackageRegistryImpl,\n ResourceFactoryRegistry,\n ResourceFactoryRegistryImpl,\n ResourceSet,\n ResourceSetImpl,\n UriConverterRegistry,\n UriConverterRegistryImpl,\n} from '@typemf/core';\nimport type { TypeMfRuntimeApi } from './api.js';\nimport { ModuleHost } from './module-host.js';\nimport { registerDefaults } from './register-defaults.js';\nimport { registerEcoreMetamodel } from './register-ecore-metamodel.js';\n\nexport interface TypeMfRuntimeOptions {\n /**\n * Whether to register the json/xmi/ecore formats and Ecore's own metamodel. Defaults to true.\n */\n registerDefaults?: boolean;\n}\n\nexport class TypeMfRuntime implements TypeMfRuntimeApi {\n readonly packageRegistry: EPackageRegistry = new EPackageRegistryImpl();\n readonly resourceFactoryRegistry: ResourceFactoryRegistry = new ResourceFactoryRegistryImpl();\n readonly uriConverterRegistry: UriConverterRegistry = new UriConverterRegistryImpl();\n readonly modules = new ModuleHost();\n\n constructor(options: TypeMfRuntimeOptions = {}) {\n if (options.registerDefaults ?? true) {\n registerDefaults(this.resourceFactoryRegistry);\n registerEcoreMetamodel(this.packageRegistry);\n }\n }\n\n createResourceSet(): ResourceSet {\n return new ResourceSetImpl(this.packageRegistry, this.resourceFactoryRegistry, this.uriConverterRegistry);\n }\n\n requireModule(name: string, range: string): unknown {\n return this.modules.require(name, range);\n }\n}\n","import semver from 'semver';\n\n/** A module that an extension declares in its manifest; loaded on its first request. */\nexport interface ModuleDeclaration {\n readonly name: string;\n readonly version: string;\n /** The id of the extension that declares the module. */\n readonly provider: string;\n readonly load: () => unknown;\n}\n\ninterface ModuleEntry {\n readonly version: string;\n readonly provider: string;\n readonly load: () => unknown;\n loaded?: { value: unknown };\n}\n\n/**\n * Holds exactly one instance of every shared module, keyed by npm package name. Modules are either\n * provided as already-loaded objects or declared with a loader that runs on the first request.\n */\nexport class ModuleHost {\n private readonly entries = new Map<string, ModuleEntry>();\n private readonly conflicts = new Map<string, string[]>();\n\n /** Adds an already-loaded module. */\n provide(name: string, version: string, module: unknown, provider = 'typemf.vscode-runtime'): void {\n this.add(name, { version, provider, load: () => module, loaded: { value: module } });\n }\n\n /** Adds a module that is loaded on its first request. */\n declare(declaration: ModuleDeclaration): void {\n if (!semver.valid(declaration.version)) {\n throw new Error(\n `Module '${declaration.name}' from '${declaration.provider}' has an invalid version '${declaration.version}'.`\n );\n }\n this.add(declaration.name, {\n version: declaration.version,\n provider: declaration.provider,\n load: declaration.load,\n });\n }\n\n has(name: string): boolean {\n return this.entries.has(name) || this.conflicts.has(name);\n }\n\n /** The module `name`, if its version satisfies `range`. Throws otherwise. */\n require(name: string, range: string): unknown {\n const providers = this.conflicts.get(name);\n if (providers) {\n throw new Error(\n `Module '${name}' is provided by more than one extension (${providers.join(', ')}); only one provider is allowed.`\n );\n }\n const entry = this.entries.get(name);\n if (!entry) {\n throw new Error(`No installed extension provides module '${name}'.`);\n }\n if (!semver.satisfies(entry.version, range, { includePrerelease: true })) {\n throw new Error(\n `Module '${name}' ${entry.version} (from '${entry.provider}') does not satisfy the requested range '${range}'.`\n );\n }\n if (!entry.loaded) {\n entry.loaded = { value: entry.load() };\n }\n return entry.loaded.value;\n }\n\n private add(name: string, entry: ModuleEntry): void {\n const conflict = this.conflicts.get(name);\n if (conflict) {\n conflict.push(entry.provider);\n return;\n }\n const existing = this.entries.get(name);\n if (existing) {\n this.entries.delete(name);\n this.conflicts.set(name, [existing.provider, entry.provider]);\n return;\n }\n this.entries.set(name, entry);\n }\n}\n","import { ResourceFactoryRegistry } from '@typemf/core';\nimport { registerJsonFormat } from '@typemf/json';\nimport { registerXmiFormat } from '@typemf/xmi';\n\n/**\n * Registers the two formats that are safe in every environment this runtime runs in - the\n * extension host (Node) and a webview (browser), both of which need to work since a shared\n * runtime instance is used from both:\n *\n * - \"json\" (@typemf/json) - JSON.parse/stringify, no environment dependency at all.\n * - \"xmi\" and \"ecore\" (@typemf/xmi) - genuine XML parsing, but @typemf/xmi's own parseXmlDocument\n * feature-detects the native browser DOMParser first and only falls back to a dynamic\n * `import('@xmldom/xmldom')` when that's absent (Node) - confirmed by reading that code\n * directly, not assumed, so this is safe to call unconditionally here.\n *\n * Deliberately does NOT register anything into a UriConverterRegistry, and never will from this\n * function specifically: every concrete UriConverter (e.g. @typemf/node's fs-backed one) is tied\n * to one specific environment, and this function's whole point is to only register things that\n * work everywhere this runtime runs. A Node-only or browser-only converter gets registered by\n * whoever assembles the runtime for that specific environment, not by this shared default.\n *\n * Exported standalone (not just called internally by TypeMfRuntime) so a plain Node script, test,\n * or any other consumer of @typemf/core's ResourceFactoryRegistry can opt into the same defaults\n * without needing @typemf/vscode-runtime or VS Code at all.\n */\nexport function registerDefaults(registry: ResourceFactoryRegistry): void {\n registerJsonFormat(registry);\n registerXmiFormat(registry);\n}\n","import { EcorePackageImpl, EPackageRegistry } from '@typemf/core';\n\n/**\n * Registers Ecore's own metamodel (EClass, EAttribute, EPackage, ...) into `registry` - a\n * deliberate, narrow exception to EPackageRegistry's own \"nothing pre-registered\" design: Ecore\n * itself is foundational, not an arbitrary domain metamodel a dependent extension opts into. Every\n * .ecore file needs it just to be parsed at all, and it's part of the modeling language itself,\n * not something layered on top of it.\n *\n * Without this, opening or creating an instance of Ecore's own classes (e.g. editing a .ecore file\n * directly) had no real path through the \"registered metamodel\" flow at all - it could only ever\n * go through the dynamic .ecore-file picker, loading a fresh, throwaway copy of Ecore's own\n * metamodel each time rather than using the one, real, already-correct EcorePackageImpl.eINSTANCE\n * every generated package already depends on.\n *\n * Exported standalone (not just called internally by TypeMfRuntime), matching register-defaults.ts's\n * own reasoning: a plain Node script, test, or any other consumer of @typemf/core's\n * EPackageRegistry can opt into this without needing @typemf/vscode-runtime or VS Code at all.\n */\nexport function registerEcoreMetamodel(registry: EPackageRegistry): void {\n registry.register(EcorePackageImpl.eINSTANCE);\n}\n","import * as vscode from 'vscode';\nimport type { WorkspaceFileSystem } from './workspace-file-system-uri-converter.js';\n\n/** `vscode.workspace.fs`, adapted to the converter's string-keyed WorkspaceFileSystem. */\nexport const vscodeWorkspaceFileSystem: WorkspaceFileSystem = {\n readFile: (uri) => Promise.resolve(vscode.workspace.fs.readFile(vscode.Uri.parse(uri))),\n async writeFile(uri, content) {\n const target = vscode.Uri.parse(uri);\n await vscode.workspace.fs.createDirectory(vscode.Uri.joinPath(target, '..'));\n await vscode.workspace.fs.writeFile(target, content);\n },\n async exists(uri) {\n try {\n await vscode.workspace.fs.stat(vscode.Uri.parse(uri));\n return true;\n } catch {\n return false;\n }\n },\n};\n","import { URI, UriConverter } from '@typemf/core';\n\n/**\n * The few file-system operations the converter needs, keyed by the document's URI text\n * (`URI.toString()` without its fragment) - what `vscode.workspace.fs` provides, minus the\n * `vscode.Uri` type, so the converter itself stays free of a `vscode` import and unit-testable.\n */\nexport interface WorkspaceFileSystem {\n readFile(uri: string): Promise<Uint8Array>;\n /** Writes `content`, creating the file's missing parent directories first. */\n writeFile(uri: string, content: Uint8Array): Promise<void>;\n exists(uri: string): Promise<boolean>;\n}\n\n/**\n * A UriConverter backed by VS Code's own file system API instead of Node's `fs`, so\n * documents on any registered file system provider - GitHub repositories opened through vscode.dev\n * or \"Remote Repositories\", remote workspaces - open and save like local files. Handles every\n * absolute URI: VS Code reports an unknown scheme as a file system error when it is actually used,\n * and `canHandle` has no way to ask which providers exist.\n */\nexport class WorkspaceFileSystemUriConverter implements UriConverter {\n constructor(private readonly fs: WorkspaceFileSystem) {}\n\n canHandle(uri: URI): boolean {\n return !uri.isRelative();\n }\n\n readBinary(uri: URI): Promise<Uint8Array> {\n return this.fs.readFile(uri.trimFragment().toString());\n }\n\n writeBinary(uri: URI, content: Uint8Array): Promise<void> {\n return this.fs.writeFile(uri.trimFragment().toString(), content);\n }\n\n exists(uri: URI): Promise<boolean> {\n return this.fs.exists(uri.trimFragment().toString());\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,EAAE,CAAC;AACpF,eAAW,aAAa,MAAO,SAAQ,IAAI,UAAU,EAAE;AACvD,eAAW,WAAW,wBAAwB,SAAS,OAAO,gBAAgB,GAAG;AAC/E,cAAQ,KAAK,mBAAmB,OAAO,EAAE;AAAA,IAC3C;AAAA,EACF;AACA,oBAAkB;AAClB,UAAQ,cAAc,KAAY,mBAAW,YAAY,iBAAiB,CAAC;AAE3E,QAAM,4BAAmC,kBAAU,oBAAoB,CAAC,GAAG,OAAO;AAClF,SAAO;AACT;AAEA,SAAS,iBAAiB,cAA+B;AACvD,SAAO,cAAc,YAAY,EAAE,YAAY;AACjD;","names":["vscode","isEPackage","join","extensions","EcorePackageImpl","vscode"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typemf/vscode-runtime",
|
|
3
3
|
"description": "API, module host and esbuild plugin of the shared TypeMF runtime for VS Code extensions.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"semver": "^7.7.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@typemf/core": "^0.
|
|
48
|
-
"@typemf/json": "^0.
|
|
49
|
-
"@typemf/node": "^0.
|
|
50
|
-
"@typemf/xmi": "^0.
|
|
47
|
+
"@typemf/core": "^0.8.0",
|
|
48
|
+
"@typemf/json": "^0.8.0",
|
|
49
|
+
"@typemf/node": "^0.8.0",
|
|
50
|
+
"@typemf/xmi": "^0.8.0",
|
|
51
51
|
"esbuild": ">=0.20.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@typemf/core": "0.
|
|
60
|
-
"@typemf/json": "0.
|
|
61
|
-
"@typemf/node": "0.
|
|
62
|
-
"@typemf/xmi": "0.
|
|
59
|
+
"@typemf/core": "0.8.0",
|
|
60
|
+
"@typemf/json": "0.8.0",
|
|
61
|
+
"@typemf/node": "0.8.0",
|
|
62
|
+
"@typemf/xmi": "0.8.0",
|
|
63
63
|
"@types/semver": "^7.7.0",
|
|
64
64
|
"@types/vscode": "^1.100.0",
|
|
65
65
|
"esbuild": "^0.24.0"
|