@kubohiroya/turbowarp-http-server 0.1.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
|
@@ -19,6 +19,333 @@
|
|
|
19
19
|
docsURI: "https://kubohiroya.github.io/turbowarp-http-server/",
|
|
20
20
|
blockIconURI: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMDAvc3ZnIiB2aWV3Qm94PSIwIDAgNDggNDgiPjxyZWN0IHg9IjYiIHk9IjEwIiB3aWR0aD0iMzYiIGhlaWdodD0iMjgiIHJ4PSI0IiBmaWxsPSIjMjU2M0VCIi8+PHBhdGggZD0iTTEyIDE4aDI0TTExIDI0aDE0TTExIDMwaDIwIiBzdHJva2U9IiNGRkYiIHN0cm9rZS13aWR0aD0iMyIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+PGNpcmNsZSBjeD0iMzQiIGN5PSIzMCIgcj0iMyIgZmlsbD0iIzIyQzU1RSIvPjwvc3ZnPg=="
|
|
21
21
|
};
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region node_modules/.pnpm/@kubohiroya+turbowarp-extension-data-editor@0.2.1_react@18.3.1/node_modules/@kubohiroya/turbowarp-extension-data-editor/dist/fixed-input-schema.js
|
|
24
|
+
var numberToken = /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$/u;
|
|
25
|
+
var invalidNumber = Object.freeze({
|
|
26
|
+
kind: "invalid",
|
|
27
|
+
code: "fixed-number-input-invalid"
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Parse a NEW numeric draft according to NP-finite-new-input-v1.
|
|
31
|
+
* Never apply this to opening/no-op raw values or use it as an owner validator.
|
|
32
|
+
* Keep the validated token so negative zero, precision and exponent spelling survive.
|
|
33
|
+
*/
|
|
34
|
+
function parseFixedNumberInput(input) {
|
|
35
|
+
if (typeof input === "number") {
|
|
36
|
+
if (!Number.isFinite(input)) return invalidNumber;
|
|
37
|
+
return Object.freeze({
|
|
38
|
+
kind: "valid",
|
|
39
|
+
token: Object.is(input, -0) ? "-0" : String(input),
|
|
40
|
+
value: input
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (typeof input !== "string") return invalidNumber;
|
|
44
|
+
const token = input.trim();
|
|
45
|
+
if (!numberToken.test(token)) return invalidNumber;
|
|
46
|
+
const value = Number(token);
|
|
47
|
+
return Number.isFinite(value) ? Object.freeze({
|
|
48
|
+
kind: "valid",
|
|
49
|
+
token,
|
|
50
|
+
value
|
|
51
|
+
}) : invalidNumber;
|
|
52
|
+
}
|
|
53
|
+
var block_editor_fixed_inputs_schema_default = {
|
|
54
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
55
|
+
$id: "https://kubohiroya.github.io/turbowarp-http-server/schemas/block-editor-fixed-inputs.schema.json",
|
|
56
|
+
$defs: {
|
|
57
|
+
"changeHandlerVariable": {
|
|
58
|
+
"type": "object",
|
|
59
|
+
"properties": { "AMOUNT": { "type": "number" } },
|
|
60
|
+
"required": ["AMOUNT"],
|
|
61
|
+
"additionalProperties": true
|
|
62
|
+
},
|
|
63
|
+
"setHttpStatus": {
|
|
64
|
+
"type": "object",
|
|
65
|
+
"properties": { "STATUS": { "type": "number" } },
|
|
66
|
+
"required": ["STATUS"],
|
|
67
|
+
"additionalProperties": true
|
|
68
|
+
},
|
|
69
|
+
"respondWithNamedBody": {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"properties": {
|
|
72
|
+
"KIND": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"enum": [
|
|
75
|
+
"structured",
|
|
76
|
+
"document",
|
|
77
|
+
"binary",
|
|
78
|
+
"asset"
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
"SCOPE": {
|
|
82
|
+
"type": "string",
|
|
83
|
+
"enum": ["target", "project"]
|
|
84
|
+
},
|
|
85
|
+
"REPRESENTATION": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"enum": [
|
|
88
|
+
"json",
|
|
89
|
+
"yaml",
|
|
90
|
+
"html",
|
|
91
|
+
"markdown",
|
|
92
|
+
"raw"
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
"MAX_BYTES": {
|
|
96
|
+
"type": "number",
|
|
97
|
+
"minimum": 1,
|
|
98
|
+
"exclusiveMaximum": 9007199254740992
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"required": [
|
|
102
|
+
"KIND",
|
|
103
|
+
"SCOPE",
|
|
104
|
+
"REPRESENTATION",
|
|
105
|
+
"MAX_BYTES"
|
|
106
|
+
],
|
|
107
|
+
"additionalProperties": true
|
|
108
|
+
},
|
|
109
|
+
"markdownHeading": {
|
|
110
|
+
"type": "object",
|
|
111
|
+
"properties": { "LEVEL": { "type": "number" } },
|
|
112
|
+
"required": ["LEVEL"],
|
|
113
|
+
"additionalProperties": true
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/fixed-input-schema.ts
|
|
119
|
+
var repository$1 = "turbowarp-http-server";
|
|
120
|
+
/** The owner JSON document is canonical; this selects a primitive field fragment. */
|
|
121
|
+
function fixedInputBundle(opcode, argument) {
|
|
122
|
+
const source = {
|
|
123
|
+
repository: repository$1,
|
|
124
|
+
path: "schemas/block-editor-fixed-inputs.schema.json",
|
|
125
|
+
symbol: `#/$defs/${opcode}/properties/${argument}`
|
|
126
|
+
};
|
|
127
|
+
const blocks = block_editor_fixed_inputs_schema_default.$defs;
|
|
128
|
+
return {
|
|
129
|
+
identity: {
|
|
130
|
+
ownerId: repository$1,
|
|
131
|
+
contractId: opcode,
|
|
132
|
+
revision: "fixed-inputs-v1",
|
|
133
|
+
variantId: argument
|
|
134
|
+
},
|
|
135
|
+
dialect: "2020-12",
|
|
136
|
+
root: {
|
|
137
|
+
retrievalUri: block_editor_fixed_inputs_schema_default.$id,
|
|
138
|
+
document: blocks[opcode].properties[argument],
|
|
139
|
+
artifact: {
|
|
140
|
+
role: "canonical-schema",
|
|
141
|
+
source
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
resources: [],
|
|
145
|
+
provenance: {
|
|
146
|
+
canonicalSources: [source, {
|
|
147
|
+
repository: repository$1,
|
|
148
|
+
path: "src/extension.ts",
|
|
149
|
+
symbol: opcode
|
|
150
|
+
}],
|
|
151
|
+
generatedFiles: [],
|
|
152
|
+
referenceSchemas: [],
|
|
153
|
+
generationSources: []
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/fixed-input-editors.ts
|
|
159
|
+
var extensionId = "kubohiroyaturbowarphttpserver";
|
|
160
|
+
var repository = "turbowarp-http-server";
|
|
161
|
+
var fields = [
|
|
162
|
+
{
|
|
163
|
+
"opcode": "changeHandlerVariable",
|
|
164
|
+
"argument": "AMOUNT",
|
|
165
|
+
"control": "number",
|
|
166
|
+
"choices": [],
|
|
167
|
+
"normalization": "identity",
|
|
168
|
+
"shape": "math_number.NUM",
|
|
169
|
+
"maxBytes": false
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"opcode": "setHttpStatus",
|
|
173
|
+
"argument": "STATUS",
|
|
174
|
+
"control": "number",
|
|
175
|
+
"choices": [],
|
|
176
|
+
"normalization": "identity",
|
|
177
|
+
"shape": "math_number.NUM",
|
|
178
|
+
"maxBytes": false
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"opcode": "respondWithNamedBody",
|
|
182
|
+
"argument": "KIND",
|
|
183
|
+
"control": "enum",
|
|
184
|
+
"choices": [
|
|
185
|
+
"structured",
|
|
186
|
+
"document",
|
|
187
|
+
"binary",
|
|
188
|
+
"asset"
|
|
189
|
+
],
|
|
190
|
+
"normalization": "lowercase",
|
|
191
|
+
"shape": "text.TEXT",
|
|
192
|
+
"maxBytes": false
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"opcode": "respondWithNamedBody",
|
|
196
|
+
"argument": "SCOPE",
|
|
197
|
+
"control": "enum",
|
|
198
|
+
"choices": ["target", "project"],
|
|
199
|
+
"normalization": "lowercase",
|
|
200
|
+
"shape": "text.TEXT",
|
|
201
|
+
"maxBytes": false
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"opcode": "respondWithNamedBody",
|
|
205
|
+
"argument": "REPRESENTATION",
|
|
206
|
+
"control": "enum",
|
|
207
|
+
"choices": [
|
|
208
|
+
"json",
|
|
209
|
+
"yaml",
|
|
210
|
+
"html",
|
|
211
|
+
"markdown",
|
|
212
|
+
"raw"
|
|
213
|
+
],
|
|
214
|
+
"normalization": "lowercase",
|
|
215
|
+
"shape": "text.TEXT",
|
|
216
|
+
"maxBytes": false
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"opcode": "respondWithNamedBody",
|
|
220
|
+
"argument": "MAX_BYTES",
|
|
221
|
+
"control": "number",
|
|
222
|
+
"choices": [],
|
|
223
|
+
"normalization": "identity",
|
|
224
|
+
"shape": "math_number.NUM",
|
|
225
|
+
"maxBytes": true
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"opcode": "markdownHeading",
|
|
229
|
+
"argument": "LEVEL",
|
|
230
|
+
"control": "number",
|
|
231
|
+
"choices": [],
|
|
232
|
+
"normalization": "identity",
|
|
233
|
+
"shape": "math_number.NUM",
|
|
234
|
+
"maxBytes": false
|
|
235
|
+
}
|
|
236
|
+
];
|
|
237
|
+
function literalString(value) {
|
|
238
|
+
if (typeof value !== "string") throw new TypeError("Expected a string literal.");
|
|
239
|
+
return value;
|
|
240
|
+
}
|
|
241
|
+
/** Legacy nonempty finite aliases are projections; opening never creates a write. */
|
|
242
|
+
function existingFixedNumber(value) {
|
|
243
|
+
if (typeof value !== "string" && typeof value !== "number" || typeof value === "string" && value.trim() === "") throw new TypeError("Unavailable numeric projection.");
|
|
244
|
+
const number = Number(value);
|
|
245
|
+
if (!Number.isFinite(number)) throw new TypeError("Unavailable numeric projection.");
|
|
246
|
+
return number;
|
|
247
|
+
}
|
|
248
|
+
function normalizeChoice(field, raw) {
|
|
249
|
+
if (field.normalization === "lowercase") return raw.toLowerCase();
|
|
250
|
+
if (field.normalization === "method") return raw.trim().toUpperCase();
|
|
251
|
+
if (field.normalization === "trim") return raw.trim();
|
|
252
|
+
if (field.normalization === "parse-format") {
|
|
253
|
+
const lower = raw.trim().toLowerCase();
|
|
254
|
+
return lower === "json" ? "JSON" : lower === "yaml" ? "YAML" : lower === "auto" ? "auto" : raw;
|
|
255
|
+
}
|
|
256
|
+
return raw;
|
|
257
|
+
}
|
|
258
|
+
function binding(field) {
|
|
259
|
+
return {
|
|
260
|
+
argument: field.argument,
|
|
261
|
+
schemaBundle: fixedInputBundle(field.opcode, field.argument),
|
|
262
|
+
control: {
|
|
263
|
+
kind: field.control,
|
|
264
|
+
...field.control === "enum" ? { choices: field.choices.map((value) => ({ value })) } : {}
|
|
265
|
+
},
|
|
266
|
+
read(value) {
|
|
267
|
+
return field.control === "number" ? existingFixedNumber(value) : normalizeChoice(field, literalString(value));
|
|
268
|
+
},
|
|
269
|
+
encode(value) {
|
|
270
|
+
if (field.control === "number") {
|
|
271
|
+
const parsed = parseFixedNumberInput(value);
|
|
272
|
+
if (parsed.kind !== "valid") throw new TypeError("Invalid new numeric input.");
|
|
273
|
+
return parsed.token;
|
|
274
|
+
}
|
|
275
|
+
const raw = literalString(value), normalized = normalizeChoice(field, raw);
|
|
276
|
+
if (!field.choices.includes(normalized)) throw new TypeError("Unsupported fixed choice.");
|
|
277
|
+
return field.shape === "menu-shadow" || field.shape === "direct-field-dropdown" ? normalized : raw;
|
|
278
|
+
},
|
|
279
|
+
validateCandidate(value) {
|
|
280
|
+
try {
|
|
281
|
+
if (field.control === "number") {
|
|
282
|
+
const number = existingFixedNumber(value);
|
|
283
|
+
if (field.maxBytes && (!Number.isSafeInteger(Math.trunc(number)) || Math.trunc(number) < 1)) return [{ message: "Invalid named body size." }];
|
|
284
|
+
return [];
|
|
285
|
+
}
|
|
286
|
+
return field.choices.includes(normalizeChoice(field, literalString(value))) ? [] : [{ message: "Unsupported fixed choice." }];
|
|
287
|
+
} catch {
|
|
288
|
+
return [{ message: "Invalid fixed input." }];
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
var fixedInputEditors = [...new Set(fields.map((f) => f.opcode))].map((opcode) => ({
|
|
294
|
+
apiVersion: 1,
|
|
295
|
+
extensionId,
|
|
296
|
+
editorId: `${opcode}-fixed-inputs`,
|
|
297
|
+
opcodes: [`${extensionId}_${opcode}`],
|
|
298
|
+
contractId: `${repository}/${opcode}`,
|
|
299
|
+
contractRevision: "fixed-inputs-v1",
|
|
300
|
+
bindings: fields.filter((field) => field.opcode === opcode).map(binding),
|
|
301
|
+
validationContext: () => ({
|
|
302
|
+
consumerId: repository,
|
|
303
|
+
nowMs: 0,
|
|
304
|
+
settings: null
|
|
305
|
+
})
|
|
306
|
+
}));
|
|
307
|
+
/** Registration follows the advertised opcode membership and the optional host capability. */
|
|
308
|
+
function fixedInputRegistration(scratch) {
|
|
309
|
+
const host = scratch ?? {};
|
|
310
|
+
let active;
|
|
311
|
+
let membership = "";
|
|
312
|
+
const removers = [];
|
|
313
|
+
let stopped = false;
|
|
314
|
+
const clear = () => {
|
|
315
|
+
host.vm?.runtime?.off?.("RUNTIME_DISPOSED", shutdown);
|
|
316
|
+
for (const remove of removers.splice(0).reverse()) remove();
|
|
317
|
+
active = void 0;
|
|
318
|
+
membership = "";
|
|
319
|
+
};
|
|
320
|
+
const shutdown = () => {
|
|
321
|
+
stopped = true;
|
|
322
|
+
clear();
|
|
323
|
+
};
|
|
324
|
+
return {
|
|
325
|
+
ensure(visibleOpcodes) {
|
|
326
|
+
const api = host.gui?.blockEditors;
|
|
327
|
+
const definitions = fixedInputEditors.filter((definition) => definition.opcodes.every((opcode) => visibleOpcodes.includes(opcode)));
|
|
328
|
+
const key = definitions.map((definition) => definition.editorId).join(",");
|
|
329
|
+
if (stopped || api === active && membership === key) return;
|
|
330
|
+
clear();
|
|
331
|
+
if (api?.apiVersion !== 1 || typeof api.registerFixedInputEditor !== "function" || !definitions.length) return;
|
|
332
|
+
try {
|
|
333
|
+
for (const definition of definitions) {
|
|
334
|
+
const remove = api.registerFixedInputEditor.call(api, definition);
|
|
335
|
+
if (typeof remove !== "function") throw new TypeError("Invalid fixed input cleanup.");
|
|
336
|
+
removers.push(remove);
|
|
337
|
+
}
|
|
338
|
+
active = api;
|
|
339
|
+
membership = key;
|
|
340
|
+
host.vm?.runtime?.on?.("RUNTIME_DISPOSED", shutdown);
|
|
341
|
+
} catch (error) {
|
|
342
|
+
clear();
|
|
343
|
+
throw error;
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
dispose: shutdown
|
|
347
|
+
};
|
|
348
|
+
}
|
|
22
349
|
var block_definitions_default = {
|
|
23
350
|
extensionName: "TurboWarp-HTTP-Server",
|
|
24
351
|
blocks: [
|
|
@@ -166,6 +493,82 @@
|
|
|
166
493
|
"description": "Returns the current request client address when available.",
|
|
167
494
|
"arguments": {}
|
|
168
495
|
},
|
|
496
|
+
{
|
|
497
|
+
"opcode": "setHandlerVariable",
|
|
498
|
+
"blockType": "COMMAND",
|
|
499
|
+
"text": "set handler variable [NAME] to [VALUE]",
|
|
500
|
+
"description": "Sets a request-local variable that is discarded when the current HTTP response completes.",
|
|
501
|
+
"arguments": {
|
|
502
|
+
"NAME": {
|
|
503
|
+
"type": "STRING",
|
|
504
|
+
"defaultValue": "value"
|
|
505
|
+
},
|
|
506
|
+
"VALUE": {
|
|
507
|
+
"type": "STRING",
|
|
508
|
+
"defaultValue": "0"
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
"opcode": "changeHandlerVariable",
|
|
514
|
+
"blockType": "COMMAND",
|
|
515
|
+
"text": "change handler variable [NAME] by [AMOUNT]",
|
|
516
|
+
"description": "Changes a request-local numeric variable using Scratch number conversion rules.",
|
|
517
|
+
"arguments": {
|
|
518
|
+
"NAME": {
|
|
519
|
+
"type": "STRING",
|
|
520
|
+
"defaultValue": "value"
|
|
521
|
+
},
|
|
522
|
+
"AMOUNT": {
|
|
523
|
+
"type": "NUMBER",
|
|
524
|
+
"defaultValue": 1
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
"opcode": "handlerVariable",
|
|
530
|
+
"blockType": "REPORTER",
|
|
531
|
+
"text": "handler variable [NAME]",
|
|
532
|
+
"description": "Returns a request-local handler variable, or an empty string when it does not exist.",
|
|
533
|
+
"arguments": { "NAME": {
|
|
534
|
+
"type": "STRING",
|
|
535
|
+
"defaultValue": "value"
|
|
536
|
+
} }
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
"opcode": "handlerVariableExists",
|
|
540
|
+
"blockType": "BOOLEAN",
|
|
541
|
+
"text": "handler variable [NAME] exists?",
|
|
542
|
+
"description": "Reports whether a request-local handler variable exists.",
|
|
543
|
+
"arguments": { "NAME": {
|
|
544
|
+
"type": "STRING",
|
|
545
|
+
"defaultValue": "value"
|
|
546
|
+
} }
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
"opcode": "deleteHandlerVariable",
|
|
550
|
+
"blockType": "COMMAND",
|
|
551
|
+
"text": "delete handler variable [NAME]",
|
|
552
|
+
"description": "Deletes a request-local handler variable.",
|
|
553
|
+
"arguments": { "NAME": {
|
|
554
|
+
"type": "STRING",
|
|
555
|
+
"defaultValue": "value"
|
|
556
|
+
} }
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
"opcode": "clearHandlerVariables",
|
|
560
|
+
"blockType": "COMMAND",
|
|
561
|
+
"text": "delete all handler variables",
|
|
562
|
+
"description": "Deletes all request-local handler variables for the current HTTP handler.",
|
|
563
|
+
"arguments": {}
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
"opcode": "listHandlerVariables",
|
|
567
|
+
"blockType": "REPORTER",
|
|
568
|
+
"text": "active handler variables",
|
|
569
|
+
"description": "Returns comma-separated names of request-local handler variables.",
|
|
570
|
+
"arguments": {}
|
|
571
|
+
},
|
|
169
572
|
{
|
|
170
573
|
"opcode": "currentAuthType",
|
|
171
574
|
"blockType": "REPORTER",
|
|
@@ -307,6 +710,42 @@
|
|
|
307
710
|
"defaultValue": "{\"ok\":true}"
|
|
308
711
|
} }
|
|
309
712
|
},
|
|
713
|
+
{
|
|
714
|
+
"opcode": "respondWithNamedBody",
|
|
715
|
+
"blockType": "COMMAND",
|
|
716
|
+
"text": "respond with named [NAMESPACE] [NAME] kind [KIND] scope [SCOPE] target [TARGET_ID] as [REPRESENTATION] max bytes [MAX_BYTES]",
|
|
717
|
+
"description": "Completes the response with a named structured, document, binary, or asset snapshot resolved by the server.",
|
|
718
|
+
"arguments": {
|
|
719
|
+
"NAMESPACE": {
|
|
720
|
+
"type": "STRING",
|
|
721
|
+
"defaultValue": "asset"
|
|
722
|
+
},
|
|
723
|
+
"NAME": {
|
|
724
|
+
"type": "STRING",
|
|
725
|
+
"defaultValue": "avatar"
|
|
726
|
+
},
|
|
727
|
+
"KIND": {
|
|
728
|
+
"type": "STRING",
|
|
729
|
+
"defaultValue": "asset"
|
|
730
|
+
},
|
|
731
|
+
"SCOPE": {
|
|
732
|
+
"type": "STRING",
|
|
733
|
+
"defaultValue": "project"
|
|
734
|
+
},
|
|
735
|
+
"TARGET_ID": {
|
|
736
|
+
"type": "STRING",
|
|
737
|
+
"defaultValue": "Stage:1"
|
|
738
|
+
},
|
|
739
|
+
"REPRESENTATION": {
|
|
740
|
+
"type": "STRING",
|
|
741
|
+
"defaultValue": "raw"
|
|
742
|
+
},
|
|
743
|
+
"MAX_BYTES": {
|
|
744
|
+
"type": "NUMBER",
|
|
745
|
+
"defaultValue": 10485760
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
},
|
|
310
749
|
{
|
|
311
750
|
"opcode": "recordHttpLog",
|
|
312
751
|
"blockType": "COMMAND",
|
|
@@ -603,8 +1042,23 @@
|
|
|
603
1042
|
"mailto",
|
|
604
1043
|
"tel"
|
|
605
1044
|
]);
|
|
1045
|
+
var NAMED_BODY_KINDS = /* @__PURE__ */ new Set([
|
|
1046
|
+
"structured",
|
|
1047
|
+
"document",
|
|
1048
|
+
"binary",
|
|
1049
|
+
"asset"
|
|
1050
|
+
]);
|
|
1051
|
+
var NAMED_BODY_SCOPES = /* @__PURE__ */ new Set(["target", "project"]);
|
|
1052
|
+
var NAMED_BODY_REPRESENTATIONS = /* @__PURE__ */ new Set([
|
|
1053
|
+
"json",
|
|
1054
|
+
"yaml",
|
|
1055
|
+
"html",
|
|
1056
|
+
"markdown",
|
|
1057
|
+
"raw"
|
|
1058
|
+
]);
|
|
606
1059
|
var TurboWarpHttpServerExtension = class {
|
|
607
1060
|
constructor() {
|
|
1061
|
+
this.fixedInputs = fixedInputRegistration(typeof Scratch === "undefined" ? void 0 : Scratch);
|
|
608
1062
|
this.serverUrl = DEFAULT_SERVER_URL;
|
|
609
1063
|
this.socket = null;
|
|
610
1064
|
this.lastReceivedMessage = "";
|
|
@@ -615,7 +1069,11 @@
|
|
|
615
1069
|
this.requestContexts = /* @__PURE__ */ new Map();
|
|
616
1070
|
this.currentRequestContextId = "";
|
|
617
1071
|
}
|
|
1072
|
+
dispose() {
|
|
1073
|
+
this.fixedInputs.dispose();
|
|
1074
|
+
}
|
|
618
1075
|
getInfo() {
|
|
1076
|
+
this.fixedInputs.ensure(blockDefinitions.map((block) => `${extensionConfig.id}_${block.opcode}`));
|
|
619
1077
|
return {
|
|
620
1078
|
id: extensionConfig.id,
|
|
621
1079
|
name: Scratch.translate(block_definitions_default.extensionName),
|
|
@@ -697,6 +1155,33 @@
|
|
|
697
1155
|
currentRequestClientAddress() {
|
|
698
1156
|
return this.currentContext()?.request.clientAddress ?? "";
|
|
699
1157
|
}
|
|
1158
|
+
setHandlerVariable(args) {
|
|
1159
|
+
const context = this.mutableCurrentContext();
|
|
1160
|
+
if (!context) return;
|
|
1161
|
+
context.handlerVariables.set(Scratch.Cast.toString(args.NAME), Scratch.Cast.toString(args.VALUE));
|
|
1162
|
+
}
|
|
1163
|
+
changeHandlerVariable(args) {
|
|
1164
|
+
const context = this.mutableCurrentContext();
|
|
1165
|
+
if (!context) return;
|
|
1166
|
+
const name = Scratch.Cast.toString(args.NAME);
|
|
1167
|
+
const current = Scratch.Cast.toNumber(context.handlerVariables.get(name) ?? "");
|
|
1168
|
+
context.handlerVariables.set(name, current + Scratch.Cast.toNumber(args.AMOUNT));
|
|
1169
|
+
}
|
|
1170
|
+
handlerVariable(args) {
|
|
1171
|
+
return this.currentContext()?.handlerVariables.get(Scratch.Cast.toString(args.NAME)) ?? "";
|
|
1172
|
+
}
|
|
1173
|
+
handlerVariableExists(args) {
|
|
1174
|
+
return this.currentContext()?.handlerVariables.has(Scratch.Cast.toString(args.NAME)) ?? false;
|
|
1175
|
+
}
|
|
1176
|
+
deleteHandlerVariable(args) {
|
|
1177
|
+
this.mutableCurrentContext()?.handlerVariables.delete(Scratch.Cast.toString(args.NAME));
|
|
1178
|
+
}
|
|
1179
|
+
clearHandlerVariables() {
|
|
1180
|
+
this.mutableCurrentContext()?.handlerVariables.clear();
|
|
1181
|
+
}
|
|
1182
|
+
listHandlerVariables() {
|
|
1183
|
+
return Array.from(this.currentContext()?.handlerVariables.keys() ?? []).join(",");
|
|
1184
|
+
}
|
|
700
1185
|
currentAuthType() {
|
|
701
1186
|
return this.currentContext()?.request.auth?.type ?? "";
|
|
702
1187
|
}
|
|
@@ -781,6 +1266,35 @@
|
|
|
781
1266
|
});
|
|
782
1267
|
this.sendResponse({ BODY: args.BODY });
|
|
783
1268
|
}
|
|
1269
|
+
respondWithNamedBody(args) {
|
|
1270
|
+
const context = this.mutableCurrentContext();
|
|
1271
|
+
if (!context) return;
|
|
1272
|
+
const kind = Scratch.Cast.toString(args.KIND).toLowerCase();
|
|
1273
|
+
const scope = Scratch.Cast.toString(args.SCOPE).toLowerCase();
|
|
1274
|
+
const representation = Scratch.Cast.toString(args.REPRESENTATION).toLowerCase();
|
|
1275
|
+
const maxBytes = Math.trunc(Scratch.Cast.toNumber(args.MAX_BYTES));
|
|
1276
|
+
if (!NAMED_BODY_KINDS.has(kind) || !NAMED_BODY_SCOPES.has(scope) || !NAMED_BODY_REPRESENTATIONS.has(representation) || !Number.isSafeInteger(maxBytes) || maxBytes < 1) {
|
|
1277
|
+
context.response.body = {
|
|
1278
|
+
kind: "unsupported",
|
|
1279
|
+
reason: "invalid_named_body"
|
|
1280
|
+
};
|
|
1281
|
+
this.completeResponse(context);
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
context.response.body = {
|
|
1285
|
+
kind: "named",
|
|
1286
|
+
reference: {
|
|
1287
|
+
namespace: Scratch.Cast.toString(args.NAMESPACE),
|
|
1288
|
+
name: Scratch.Cast.toString(args.NAME),
|
|
1289
|
+
kind,
|
|
1290
|
+
scope
|
|
1291
|
+
},
|
|
1292
|
+
representation,
|
|
1293
|
+
...scope === "target" ? { targetId: Scratch.Cast.toString(args.TARGET_ID) } : {},
|
|
1294
|
+
maxBytes
|
|
1295
|
+
};
|
|
1296
|
+
this.completeResponse(context);
|
|
1297
|
+
}
|
|
784
1298
|
receiveBridgeRequestForTest(request) {
|
|
785
1299
|
this.acceptBridgeRequest(request);
|
|
786
1300
|
}
|
|
@@ -898,7 +1412,8 @@
|
|
|
898
1412
|
headers: {},
|
|
899
1413
|
body: { kind: "empty" },
|
|
900
1414
|
completed: false
|
|
901
|
-
}
|
|
1415
|
+
},
|
|
1416
|
+
handlerVariables: /* @__PURE__ */ new Map()
|
|
902
1417
|
});
|
|
903
1418
|
this.currentRequestContextId = request.id;
|
|
904
1419
|
this.startRequestHat();
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Binary resource semantics
|
|
2
|
+
|
|
3
|
+
Deploy IR v2はbinary payloadをJSON文字列やbase64として保持せず、永続objectを示す`binary-ref`と、実行時streamを示すaffine `binary-body`を区別します。この層はCloudflare R2、Firebase Cloud Storage、Node filesystem等の製品型を参照しません。
|
|
4
|
+
|
|
5
|
+
## 値とresource
|
|
6
|
+
|
|
7
|
+
`binary-ref`はIR JSONへ格納できるlogical descriptorです。
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"namespace": "asset",
|
|
12
|
+
"key": "images/hero.png",
|
|
13
|
+
"contentType": "image/png",
|
|
14
|
+
"size": 1234,
|
|
15
|
+
"integrity": "sha256:<lowercase-hex-64>",
|
|
16
|
+
"revision": "opaque-adapter-token"
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`namespace`は小文字英字で始まり、小文字英数字・`.`・`-`だけを使う64文字以下のlogical ID、`key`は512文字以下です。absolute path、backslash、空segment、`.`/`..` segment、NULを拒否します。`revision`はintegrityやplatform間共通ETagではなく、adapterだけが解釈するopaque tokenです。
|
|
21
|
+
|
|
22
|
+
`binary-body`はIR JSONへ本体を格納しないresource bindingです。producerがbinding IDを宣言し、putまたはbinary responseが最大1回consumeします。clone、tee、base64化、同じbodyの保存とresponseへの併用はMVP対象外です。分岐後に利用するbodyは全continuing branchで同じ所有状態でなければならず、複数回実行し得るloopから外側bodyをconsumeできません。
|
|
23
|
+
|
|
24
|
+
## IR operation
|
|
25
|
+
|
|
26
|
+
| statement | producer/consumer | requirement |
|
|
27
|
+
| --- | --- | --- |
|
|
28
|
+
| `asset-resolve` | locatorから`binary-ref \| null` valueを生成 | `object-storage` |
|
|
29
|
+
| `request-body-binary` | request streamから`binary-body`を生成 | `streaming-body` |
|
|
30
|
+
| `asset-object-get` | `binary-ref`から`binary-body`を生成 | `object-storage`, `streaming-body` |
|
|
31
|
+
| `asset-object-put` | `binary-body`をconsumeし`binary-ref`を生成 | `object-storage` |
|
|
32
|
+
| `asset-object-delete` | refまたはlocatorをidempotentに削除しbooleanを生成 | `object-storage` |
|
|
33
|
+
| `respond-binary` | `binary-body`をconsumeしてresponseを完了 | `streaming-body` |
|
|
34
|
+
|
|
35
|
+
producer/consumer集合は閉じており、未知statementがresource bindingを生成・複製・消費できません。`respond-binary`は通常の`respond`と同じterminal responseです。
|
|
36
|
+
|
|
37
|
+
## Size policy
|
|
38
|
+
|
|
39
|
+
compiler policyの既定`maxBinaryBytes`は16 MiB(16777216 bytes)です。request、get、putは1以上policy以下のliteral `maxBytes`を必須とします。実行時のeffective limitは次です。
|
|
40
|
+
|
|
41
|
+
```text
|
|
42
|
+
min(operation maxBytes, compiler maxBinaryBytes, target maxBinaryBytes)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
既知のsizeが上限を超える場合はstream開始前に拒否します。sizeがない、または信用できない場合もchunkごとにcountし、超過時にiteratorをcancelして`BINARY_TOO_LARGE`とします。production adapter contractはstreamingを許し、bufferを要求しません。test用`InMemoryBinaryObjectStore`だけが決定的なfixture比較のためbufferします。
|
|
46
|
+
|
|
47
|
+
## Metadataとresponse
|
|
48
|
+
|
|
49
|
+
- `contentType`: CR/LFを含まないmedia type
|
|
50
|
+
- `size`: 0以上のsafe integer
|
|
51
|
+
- `integrity`: `sha256:<lowercase-hex-64>`
|
|
52
|
+
- `revision`: 1〜256文字のopaque token
|
|
53
|
+
- attachment filename: metadataとは別のresponse dispositionで指定し、RFC 5987形式へencode
|
|
54
|
+
|
|
55
|
+
入力metadataのsize/integrityが実データと一致しない場合は保存しません。binary byte列、locator、platform errorはdiagnosticやHTTP error responseへ含めません。
|
|
56
|
+
|
|
57
|
+
## Runtime errors
|
|
58
|
+
|
|
59
|
+
| code | HTTP status |
|
|
60
|
+
| --- | ---: |
|
|
61
|
+
| `BINARY_INVALID_REF` | 422 |
|
|
62
|
+
| `BINARY_NOT_FOUND` | 404 |
|
|
63
|
+
| `BINARY_TOO_LARGE` | 413 |
|
|
64
|
+
| `BINARY_INTEGRITY_MISMATCH` | 502 |
|
|
65
|
+
| `BINARY_BODY_CONSUMED` | 500 |
|
|
66
|
+
| `BINARY_STORAGE_FAILURE` | 502 |
|
|
67
|
+
|
|
68
|
+
HTTP JSON envelope化とstream開始後のabort処理はcompiler pipeline/adapter error boundaryの責務です。
|
|
69
|
+
|
|
70
|
+
## Asset Cache manifest境界
|
|
71
|
+
|
|
72
|
+
対応syntaxの正本は`@kubohiroya/turbowarp-asset-cache` 0.1.0のmanifest format 2です。このmanifestは全blockを明示的にbrowser-onlyと宣言し、server operation hintを持ちません。`registerAsset`はURL、costume、sound、runtime text等をまとめるbrowser registry操作であり、object storage putへ近似しません。`isLoaded`、renderer、audio、IndexedDB cache blockも同様にbrowser-onlyとして`TW2_UNSUPPORTED_OPERATION`になります。
|
|
73
|
+
|
|
74
|
+
したがって現時点のAsset Cache manifestからbinary IR actionへloweringされるopcodeはありません。将来manifestにcompiler allowlistと一致するserver hint/専用blockが追加された場合だけ対応します。request uploadは対応source opcodeがないためdirect IRからのみ生成できます。この境界により、browser意味論を推測してcloud storageへ誤変換しません。
|
|
75
|
+
|
|
76
|
+
## Adapter contract
|
|
77
|
+
|
|
78
|
+
`BinaryObjectStore`は`resolve/get/put/delete`をlogical locatorとstreamで提供します。getの未存在は`null`、deleteの未存在は`false`、storage failureは例外として区別します。targetは`object-storage`、`streaming-body`、最大byte数をcapability planで宣言します。IRやfrontendを変更せず別adapterを追加できます。
|
|
79
|
+
|
|
80
|
+
Cloudflare R2/D1とFirebase Cloud Storage/Firestoreへの具体的なmapping、key prefix、設定、整合性、smoke test方針は[IR v2 platform storage adapter](platform-storage-adapters.ja.md)を参照してください。
|
|
81
|
+
|
|
82
|
+
## ロールバック
|
|
83
|
+
|
|
84
|
+
rollbackはbinary resourceを含む生成・deployを停止するだけで、既存cloud objectやbrowser側Asset Cache dataを自動削除しません。
|