@cynodia/axiom-runtime 0.3.1-alpha.1
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/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/dom.d.ts +42 -0
- package/dist/dom.js +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +9 -0
- package/dist/memory-host.d.ts +52 -0
- package/dist/memory-host.js +145 -0
- package/dist/mutation/mutation-engine.d.ts +44 -0
- package/dist/mutation/mutation-engine.js +92 -0
- package/dist/mutation/resolve-location.d.ts +37 -0
- package/dist/mutation/resolve-location.js +108 -0
- package/dist/mutation/store.d.ts +14 -0
- package/dist/mutation/store.js +19 -0
- package/dist/mutation/transaction.d.ts +21 -0
- package/dist/mutation/transaction.js +45 -0
- package/dist/mutation/values.d.ts +17 -0
- package/dist/mutation/values.js +73 -0
- package/dist/runtime.d.ts +48 -0
- package/dist/runtime.js +1149 -0
- package/dist/source.d.ts +5 -0
- package/dist/source.js +71 -0
- package/package.json +40 -0
package/dist/source.d.ts
ADDED
package/dist/source.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
/**
|
|
3
|
+
* The runtime modules, in dependency order. Each is authored as ordinary TypeScript —
|
|
4
|
+
* type-checked and unit tested — and imports nothing at run time except its siblings,
|
|
5
|
+
* so concatenating them and dropping the module syntax produces a complete browser
|
|
6
|
+
* bundle without a bundler.
|
|
7
|
+
*/
|
|
8
|
+
const RUNTIME_MODULES = [
|
|
9
|
+
'./mutation/values.js',
|
|
10
|
+
'./mutation/store.js',
|
|
11
|
+
'./mutation/transaction.js',
|
|
12
|
+
'./mutation/resolve-location.js',
|
|
13
|
+
'./mutation/mutation-engine.js',
|
|
14
|
+
'./runtime.js',
|
|
15
|
+
];
|
|
16
|
+
const BUNDLED_BASENAMES = RUNTIME_MODULES.map((module) => module.slice(module.lastIndexOf('/') + 1));
|
|
17
|
+
export class UnbundledDependencyError extends Error {
|
|
18
|
+
constructor(module, specifier) {
|
|
19
|
+
super(`${module} imports "${specifier}" at run time, but only the runtime's own modules are ` +
|
|
20
|
+
`inlined into a page. Import it as a type, inline the value, or resolve it during ` +
|
|
21
|
+
`compilation instead.`);
|
|
22
|
+
this.name = 'UnbundledDependencyError';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Removes `import` statements and `export` keywords so the modules share one scope.
|
|
27
|
+
* An import of anything outside the bundle is an error rather than a silent omission:
|
|
28
|
+
* stripping it would leave an undefined identifier in the browser.
|
|
29
|
+
*/
|
|
30
|
+
function stripModuleSyntax(source, module) {
|
|
31
|
+
const kept = [];
|
|
32
|
+
let insideImport = false;
|
|
33
|
+
let pendingImport = '';
|
|
34
|
+
const checkSpecifier = (statement) => {
|
|
35
|
+
const specifier = /from\s+'([^']+)'/.exec(statement)?.[1];
|
|
36
|
+
if (!specifier) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const basename = specifier.slice(specifier.lastIndexOf('/') + 1);
|
|
40
|
+
if (!BUNDLED_BASENAMES.includes(basename)) {
|
|
41
|
+
throw new UnbundledDependencyError(module, specifier);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
for (const line of source.split('\n')) {
|
|
45
|
+
if (insideImport) {
|
|
46
|
+
pendingImport += ` ${line.trim()}`;
|
|
47
|
+
if (line.trimEnd().endsWith(';')) {
|
|
48
|
+
insideImport = false;
|
|
49
|
+
checkSpecifier(pendingImport);
|
|
50
|
+
pendingImport = '';
|
|
51
|
+
}
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const trimmed = line.trimStart();
|
|
55
|
+
if (trimmed.startsWith('import ')) {
|
|
56
|
+
if (trimmed.trimEnd().endsWith(';')) {
|
|
57
|
+
checkSpecifier(trimmed);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
insideImport = true;
|
|
61
|
+
pendingImport = trimmed;
|
|
62
|
+
}
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
kept.push(line.startsWith('export ') ? line.slice('export '.length) : line);
|
|
66
|
+
}
|
|
67
|
+
return kept.join('\n');
|
|
68
|
+
}
|
|
69
|
+
export function createRuntimeModuleSource() {
|
|
70
|
+
return RUNTIME_MODULES.map((module) => stripModuleSyntax(readFileSync(new URL(module, import.meta.url), 'utf8'), module)).join('\n');
|
|
71
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cynodia/axiom-runtime",
|
|
3
|
+
"version": "0.3.1-alpha.1",
|
|
4
|
+
"description": "Domain-independent runtime that executes an Axiom application graph.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "AskTech AS",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/cynodia/axiom.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/cynodia/axiom",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/cynodia/axiom/issues"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist/**/*.js",
|
|
21
|
+
"dist/**/*.d.ts",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@cynodia/axiom-core": "0.3.1-alpha.1"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc -b tsconfig.json tsconfig.test.json",
|
|
38
|
+
"test": "node --test dist-test/**/*.test.js"
|
|
39
|
+
}
|
|
40
|
+
}
|