@kubohiroya/turbowarp-http-server 0.2.0 → 0.2.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/README.ja.md +29 -13
- package/README.md +101 -42
- package/dist/cli.js +131 -17
- package/dist/cli.js.map +1 -1
- package/dist/compiler/adapters/cloudflare.d.ts +2 -0
- package/dist/compiler/adapters/cloudflare.js +477 -0
- package/dist/compiler/adapters/cloudflare.js.map +1 -0
- package/dist/compiler/adapters/firebase.d.ts +2 -0
- package/dist/compiler/adapters/firebase.js +489 -0
- package/dist/compiler/adapters/firebase.js.map +1 -0
- package/dist/compiler/adapters/index.d.ts +2 -0
- package/dist/compiler/adapters/index.js +3 -0
- package/dist/compiler/adapters/index.js.map +1 -0
- package/dist/compiler/binary/codec.d.ts +4 -0
- package/dist/compiler/binary/codec.js +45 -0
- package/dist/compiler/binary/codec.js.map +1 -0
- package/dist/compiler/binary/error.d.ts +3 -0
- package/dist/compiler/binary/error.js +21 -0
- package/dist/compiler/binary/error.js.map +1 -0
- package/dist/compiler/binary/index.d.ts +4 -0
- package/dist/compiler/binary/index.js +5 -0
- package/dist/compiler/binary/index.js.map +1 -0
- package/dist/compiler/binary/runtime.d.ts +18 -0
- package/dist/compiler/binary/runtime.js +123 -0
- package/dist/compiler/binary/runtime.js.map +1 -0
- package/dist/compiler/binary/types.d.ts +17 -0
- package/dist/compiler/binary/types.js +2 -0
- package/dist/compiler/binary/types.js.map +1 -0
- package/dist/compiler/feature-flags.d.ts +4 -0
- package/dist/compiler/feature-flags.js +4 -0
- package/dist/compiler/feature-flags.js.map +1 -0
- package/dist/compiler/index.d.ts +35 -0
- package/dist/compiler/index.js +84 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/ir-v2/canonical.d.ts +3 -0
- package/dist/compiler/ir-v2/canonical.js +50 -0
- package/dist/compiler/ir-v2/canonical.js.map +1 -0
- package/dist/compiler/ir-v2/index.d.ts +4 -0
- package/dist/compiler/ir-v2/index.js +5 -0
- package/dist/compiler/ir-v2/index.js.map +1 -0
- package/dist/compiler/ir-v2/parse.d.ts +10 -0
- package/dist/compiler/ir-v2/parse.js +753 -0
- package/dist/compiler/ir-v2/parse.js.map +1 -0
- package/dist/compiler/ir-v2/strict-json.d.ts +4 -0
- package/dist/compiler/ir-v2/strict-json.js +133 -0
- package/dist/compiler/ir-v2/strict-json.js.map +1 -0
- package/dist/compiler/ir-v2/types.d.ts +412 -0
- package/dist/compiler/ir-v2/types.js +84 -0
- package/dist/compiler/ir-v2/types.js.map +1 -0
- package/dist/compiler/kvs/lowering.d.ts +13 -0
- package/dist/compiler/kvs/lowering.js +77 -0
- package/dist/compiler/kvs/lowering.js.map +1 -0
- package/dist/compiler/manifest/error.d.ts +7 -0
- package/dist/compiler/manifest/error.js +9 -0
- package/dist/compiler/manifest/error.js.map +1 -0
- package/dist/compiler/manifest/index.d.ts +6 -0
- package/dist/compiler/manifest/index.js +7 -0
- package/dist/compiler/manifest/index.js.map +1 -0
- package/dist/compiler/manifest/operations.d.ts +12 -0
- package/dist/compiler/manifest/operations.js +60 -0
- package/dist/compiler/manifest/operations.js.map +1 -0
- package/dist/compiler/manifest/parse.d.ts +9 -0
- package/dist/compiler/manifest/parse.js +280 -0
- package/dist/compiler/manifest/parse.js.map +1 -0
- package/dist/compiler/manifest/registry.d.ts +3 -0
- package/dist/compiler/manifest/registry.js +48 -0
- package/dist/compiler/manifest/registry.js.map +1 -0
- package/dist/compiler/manifest/resolve.d.ts +14 -0
- package/dist/compiler/manifest/resolve.js +116 -0
- package/dist/compiler/manifest/resolve.js.map +1 -0
- package/dist/compiler/manifest/types.d.ts +95 -0
- package/dist/compiler/manifest/types.js +3 -0
- package/dist/compiler/manifest/types.js.map +1 -0
- package/dist/compiler/named-body/index.d.ts +1 -0
- package/dist/compiler/named-body/index.js +2 -0
- package/dist/compiler/named-body/index.js.map +1 -0
- package/dist/compiler/named-body/lowering.d.ts +18 -0
- package/dist/compiler/named-body/lowering.js +83 -0
- package/dist/compiler/named-body/lowering.js.map +1 -0
- package/dist/compiler/pipeline/compiler.d.ts +18 -0
- package/dist/compiler/pipeline/compiler.js +105 -0
- package/dist/compiler/pipeline/compiler.js.map +1 -0
- package/dist/compiler/pipeline/core-generator.d.ts +3 -0
- package/dist/compiler/pipeline/core-generator.js +483 -0
- package/dist/compiler/pipeline/core-generator.js.map +1 -0
- package/dist/compiler/pipeline/index.d.ts +5 -0
- package/dist/compiler/pipeline/index.js +6 -0
- package/dist/compiler/pipeline/index.js.map +1 -0
- package/dist/compiler/pipeline/registry.d.ts +7 -0
- package/dist/compiler/pipeline/registry.js +17 -0
- package/dist/compiler/pipeline/registry.js.map +1 -0
- package/dist/compiler/pipeline/requirements.d.ts +9 -0
- package/dist/compiler/pipeline/requirements.js +135 -0
- package/dist/compiler/pipeline/requirements.js.map +1 -0
- package/dist/compiler/pipeline/types.d.ts +65 -0
- package/dist/compiler/pipeline/types.js +2 -0
- package/dist/compiler/pipeline/types.js.map +1 -0
- package/dist/compiler/runtime/error.d.ts +6 -0
- package/dist/compiler/runtime/error.js +9 -0
- package/dist/compiler/runtime/error.js.map +1 -0
- package/dist/compiler/runtime/index.d.ts +1 -0
- package/dist/compiler/runtime/index.js +2 -0
- package/dist/compiler/runtime/index.js.map +1 -0
- package/dist/compiler/structured-data/index.d.ts +3 -0
- package/dist/compiler/structured-data/index.js +4 -0
- package/dist/compiler/structured-data/index.js.map +1 -0
- package/dist/compiler/structured-data/lowering.d.ts +30 -0
- package/dist/compiler/structured-data/lowering.js +202 -0
- package/dist/compiler/structured-data/lowering.js.map +1 -0
- package/dist/compiler/structured-data/path.d.ts +2 -0
- package/dist/compiler/structured-data/path.js +60 -0
- package/dist/compiler/structured-data/path.js.map +1 -0
- package/dist/compiler/structured-data/runtime.d.ts +20 -0
- package/dist/compiler/structured-data/runtime.js +210 -0
- package/dist/compiler/structured-data/runtime.js.map +1 -0
- package/dist/compiler/turbowarp-v2.d.ts +8 -0
- package/dist/compiler/turbowarp-v2.js +479 -0
- package/dist/compiler/turbowarp-v2.js.map +1 -0
- package/dist/compiler/validator/index.d.ts +4 -0
- package/dist/compiler/validator/index.js +5 -0
- package/dist/compiler/validator/index.js.map +1 -0
- package/dist/compiler/validator/ir-validator.d.ts +10 -0
- package/dist/compiler/validator/ir-validator.js +463 -0
- package/dist/compiler/validator/ir-validator.js.map +1 -0
- package/dist/compiler/validator/resource-lifetime.d.ts +18 -0
- package/dist/compiler/validator/resource-lifetime.js +106 -0
- package/dist/compiler/validator/resource-lifetime.js.map +1 -0
- package/dist/compiler/validator/turbowarp-subset.d.ts +3 -0
- package/dist/compiler/validator/turbowarp-subset.js +241 -0
- package/dist/compiler/validator/turbowarp-subset.js.map +1 -0
- package/dist/compiler/validator/types.d.ts +30 -0
- package/dist/compiler/validator/types.js +7 -0
- package/dist/compiler/validator/types.js.map +1 -0
- package/dist/config.d.ts +11 -0
- package/dist/config.js +12 -0
- package/dist/config.js.map +1 -0
- package/dist/digest-cli.js +0 -0
- package/dist/extension-manifest.json +102 -0
- package/dist/named-body.d.ts +57 -0
- package/dist/named-body.js +396 -0
- package/dist/named-body.js.map +1 -0
- package/dist/named-data-namespace.d.ts +3 -0
- package/dist/named-data-namespace.js +6 -0
- package/dist/named-data-namespace.js.map +1 -0
- package/dist/protocol.d.ts +13 -1
- package/dist/protocol.js +34 -0
- package/dist/protocol.js.map +1 -1
- package/dist/resource-named-body-provider.d.ts +8 -0
- package/dist/resource-named-body-provider.js +88 -0
- package/dist/resource-named-body-provider.js.map +1 -0
- package/dist/server.d.ts +10 -1
- package/dist/server.js +37 -7
- package/dist/server.js.map +1 -1
- package/dist/turbowarp-http-server.js +516 -1
- package/docs/binary-resource-semantics.ja.md +84 -0
- package/docs/cloudflare-worker-compiler.ja.md +90 -0
- package/docs/compiler-manifest-registry.ja.md +79 -0
- package/docs/compiler-platform-pipeline.ja.md +94 -0
- package/docs/deploy-ir-v2.ja.md +123 -0
- package/docs/fixed-input-editors.ja.md +23 -0
- package/docs/index.html +80 -0
- package/docs/ir-v2-conformance.ja.md +65 -0
- package/docs/named-response-body.ja.md +120 -0
- package/docs/platform-storage-adapters.ja.md +99 -0
- package/docs/server-executable-subset.ja.md +88 -0
- package/docs/structured-data-lowering.ja.md +63 -0
- package/examples/compiler/message-app.v2.ir.json +41 -0
- package/package.json +44 -20
- package/schemas/block-editor-fixed-inputs.schema.json +85 -0
- package/schemas/compiler-extension-manifest.schema.json +126 -0
- package/schemas/compiler-manifest-lock-v1.schema.json +48 -0
- package/schemas/deploy-ir-v2.schema.json +835 -0
- package/schemas/ir-v2-conformance-fixture.schema.json +44 -0
- package/src/block-definitions.json +76 -0
- package/src/cli.ts +136 -23
- package/src/compiler/adapters/cloudflare.ts +510 -0
- package/src/compiler/adapters/firebase.ts +538 -0
- package/src/compiler/adapters/index.ts +2 -0
- package/src/compiler/binary/codec.ts +61 -0
- package/src/compiler/binary/error.ts +25 -0
- package/src/compiler/binary/index.ts +4 -0
- package/src/compiler/binary/runtime.ts +133 -0
- package/src/compiler/binary/types.ts +26 -0
- package/src/compiler/feature-flags.ts +7 -0
- package/src/compiler/index.ts +114 -0
- package/src/compiler/ir-v2/canonical.ts +46 -0
- package/src/compiler/ir-v2/index.ts +9 -0
- package/src/compiler/ir-v2/parse.ts +921 -0
- package/src/compiler/ir-v2/strict-json.ts +129 -0
- package/src/compiler/ir-v2/types.ts +462 -0
- package/src/compiler/kvs/lowering.ts +88 -0
- package/src/compiler/manifest/error.ts +29 -0
- package/src/compiler/manifest/index.ts +17 -0
- package/src/compiler/manifest/operations.ts +175 -0
- package/src/compiler/manifest/parse.ts +390 -0
- package/src/compiler/manifest/registry.ts +74 -0
- package/src/compiler/manifest/resolve.ts +159 -0
- package/src/compiler/manifest/types.ts +112 -0
- package/src/compiler/named-body/index.ts +1 -0
- package/src/compiler/named-body/lowering.ts +186 -0
- package/src/compiler/pipeline/compiler.ts +138 -0
- package/src/compiler/pipeline/core-generator.ts +486 -0
- package/src/compiler/pipeline/index.ts +5 -0
- package/src/compiler/pipeline/registry.ts +18 -0
- package/src/compiler/pipeline/requirements.ts +139 -0
- package/src/compiler/pipeline/types.ts +59 -0
- package/src/compiler/runtime/error.ts +11 -0
- package/src/compiler/runtime/index.ts +1 -0
- package/src/compiler/structured-data/index.ts +3 -0
- package/src/compiler/structured-data/lowering.ts +314 -0
- package/src/compiler/structured-data/path.ts +53 -0
- package/src/compiler/structured-data/runtime.ts +221 -0
- package/src/compiler/turbowarp-v2.ts +610 -0
- package/src/compiler/validator/index.ts +4 -0
- package/src/compiler/validator/ir-validator.ts +812 -0
- package/src/compiler/validator/resource-lifetime.ts +153 -0
- package/src/compiler/validator/turbowarp-subset.ts +387 -0
- package/src/compiler/validator/types.ts +68 -0
- package/src/extension.ts +87 -1
- package/src/fixed-input-editors.ts +181 -0
- package/src/fixed-input-schema.ts +15 -0
- package/src/named-body.ts +495 -0
- package/src/named-data-namespace.ts +6 -0
- package/src/protocol.ts +50 -1
- package/src/resource-named-body-provider.ts +106 -0
- package/src/server.ts +88 -8
- package/docs/turbowarp-http-server.architecture.visual-check.1440x900.dark.png +0 -0
- package/docs/turbowarp-http-server.architecture.visual-check.1440x900.light.png +0 -0
- package/docs/turbowarp-http-server.architecture.visual-check.2048x1320.dark.png +0 -0
- package/docs/turbowarp-http-server.architecture.visual-check.2048x1320.light.png +0 -0
- package/docs/turbowarp-http-server.architecture.visual-check.html +0 -32
- package/docs/turbowarp-http-server.architecture.visual-check.json +0 -547
- package/schemas/extension-manifest.schema.json +0 -49
- package/src/extension-manifest.ts +0 -149
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import type {Plugin} from 'vite';
|
|
2
|
-
|
|
3
|
-
export const EXTENSION_MANIFEST_FORMAT_VERSION = 1 as const;
|
|
4
|
-
|
|
5
|
-
export interface ExtensionManifestArgument {
|
|
6
|
-
id: string;
|
|
7
|
-
type: string;
|
|
8
|
-
menu?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface ExtensionManifestBlock {
|
|
12
|
-
opcode: string;
|
|
13
|
-
blockType: string;
|
|
14
|
-
arguments: ExtensionManifestArgument[];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface ExtensionManifestMenu {
|
|
18
|
-
id: string;
|
|
19
|
-
acceptReporters: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface ExtensionManifest {
|
|
23
|
-
formatVersion: typeof EXTENSION_MANIFEST_FORMAT_VERSION;
|
|
24
|
-
id: string;
|
|
25
|
-
blocks: ExtensionManifestBlock[];
|
|
26
|
-
menus: ExtensionManifestMenu[];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface ExtensionManifestPluginOptions {
|
|
30
|
-
id: string;
|
|
31
|
-
definitions: unknown;
|
|
32
|
-
fileName?: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function createExtensionManifest(id: string, definitions: unknown): ExtensionManifest {
|
|
36
|
-
if (!/^[a-z0-9]+$/.test(id)) {
|
|
37
|
-
throw new TypeError('Extension manifest ID must contain only lowercase letters and numbers.');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const source = requireRecord(definitions, 'Block definitions');
|
|
41
|
-
const sourceBlocks = source.blocks;
|
|
42
|
-
if (!Array.isArray(sourceBlocks)) {
|
|
43
|
-
throw new TypeError('Block definitions must contain a blocks array.');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const menus = normalizeMenus(source.menus);
|
|
47
|
-
const menuIds = new Set(menus.map((menu) => menu.id));
|
|
48
|
-
const seenOpcodes = new Set<string>();
|
|
49
|
-
const blocks = sourceBlocks.map((block, index) => {
|
|
50
|
-
const normalized = normalizeBlock(block, index, menuIds);
|
|
51
|
-
if (seenOpcodes.has(normalized.opcode)) {
|
|
52
|
-
throw new TypeError(`Duplicate block opcode: ${normalized.opcode}`);
|
|
53
|
-
}
|
|
54
|
-
seenOpcodes.add(normalized.opcode);
|
|
55
|
-
return normalized;
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
formatVersion: EXTENSION_MANIFEST_FORMAT_VERSION,
|
|
60
|
-
id,
|
|
61
|
-
blocks: blocks.sort((left, right) => compareIds(left.opcode, right.opcode)),
|
|
62
|
-
menus
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function serializeExtensionManifest(id: string, definitions: unknown): string {
|
|
67
|
-
return `${JSON.stringify(createExtensionManifest(id, definitions), null, 2)}\n`;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function extensionManifestPlugin(options: ExtensionManifestPluginOptions): Plugin {
|
|
71
|
-
return {
|
|
72
|
-
name: 'extension-api-manifest',
|
|
73
|
-
apply: 'build',
|
|
74
|
-
enforce: 'post',
|
|
75
|
-
generateBundle() {
|
|
76
|
-
this.emitFile({
|
|
77
|
-
type: 'asset',
|
|
78
|
-
fileName: options.fileName ?? 'extension-manifest.json',
|
|
79
|
-
source: serializeExtensionManifest(options.id, options.definitions)
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function normalizeBlock(
|
|
86
|
-
value: unknown,
|
|
87
|
-
index: number,
|
|
88
|
-
menuIds: ReadonlySet<string>
|
|
89
|
-
): ExtensionManifestBlock {
|
|
90
|
-
const block = requireRecord(value, `Block at index ${index}`);
|
|
91
|
-
const opcode = requireNonEmptyString(block.opcode, `Block at index ${index} opcode`);
|
|
92
|
-
const blockType = requireNonEmptyString(block.blockType, `Block ${opcode} blockType`);
|
|
93
|
-
const sourceArguments = block.arguments ?? {};
|
|
94
|
-
const argumentRecord = requireRecord(sourceArguments, `Block ${opcode} arguments`);
|
|
95
|
-
const argumentsList = Object.entries(argumentRecord).map(([argumentId, argument]) => {
|
|
96
|
-
requireNonEmptyString(argumentId, `Block ${opcode} argument ID`);
|
|
97
|
-
const definition = requireRecord(argument, `Block ${opcode} argument ${argumentId}`);
|
|
98
|
-
const type = requireNonEmptyString(
|
|
99
|
-
definition.type,
|
|
100
|
-
`Block ${opcode} argument ${argumentId} type`
|
|
101
|
-
);
|
|
102
|
-
const menu = definition.menu;
|
|
103
|
-
if (menu !== undefined && (typeof menu !== 'string' || !menuIds.has(menu))) {
|
|
104
|
-
throw new TypeError(`Block ${opcode} argument ${argumentId} references unknown menu: ${menu}`);
|
|
105
|
-
}
|
|
106
|
-
return menu === undefined ? {id: argumentId, type} : {id: argumentId, type, menu};
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
return {
|
|
110
|
-
opcode,
|
|
111
|
-
blockType,
|
|
112
|
-
arguments: argumentsList.sort((left, right) => compareIds(left.id, right.id))
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function normalizeMenus(value: unknown): ExtensionManifestMenu[] {
|
|
117
|
-
const menuRecord = requireRecord(value ?? {}, 'Block definition menus');
|
|
118
|
-
return Object.entries(menuRecord)
|
|
119
|
-
.map(([id, menu]) => {
|
|
120
|
-
requireNonEmptyString(id, 'Menu ID');
|
|
121
|
-
const definition = requireRecord(menu, `Menu ${id}`);
|
|
122
|
-
const acceptReporters = definition.acceptReporters ?? false;
|
|
123
|
-
if (typeof acceptReporters !== 'boolean') {
|
|
124
|
-
throw new TypeError(`Menu ${id} acceptReporters must be a boolean.`);
|
|
125
|
-
}
|
|
126
|
-
return {id, acceptReporters};
|
|
127
|
-
})
|
|
128
|
-
.sort((left, right) => compareIds(left.id, right.id));
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
|
132
|
-
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
133
|
-
throw new TypeError(`${label} must be an object.`);
|
|
134
|
-
}
|
|
135
|
-
return value as Record<string, unknown>;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function requireNonEmptyString(value: unknown, label: string): string {
|
|
139
|
-
if (typeof value !== 'string' || value.length === 0) {
|
|
140
|
-
throw new TypeError(`${label} must be a non-empty string.`);
|
|
141
|
-
}
|
|
142
|
-
return value;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function compareIds(left: string, right: string): number {
|
|
146
|
-
if (left < right) return -1;
|
|
147
|
-
if (left > right) return 1;
|
|
148
|
-
return 0;
|
|
149
|
-
}
|