firefly-compiler 0.4.51 → 0.4.52
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/.hintrc +4 -4
- package/.vscode/settings.json +4 -4
- package/bin/Release.ff +153 -153
- package/bin/firefly.mjs +1 -1
- package/compiler/Builder.ff +257 -257
- package/compiler/Compiler.ff +227 -227
- package/compiler/Dependencies.ff +186 -186
- package/compiler/DependencyLock.ff +17 -17
- package/compiler/JsEmitter.ff +946 -946
- package/compiler/LspHook.ff +202 -202
- package/compiler/ModuleCache.ff +178 -178
- package/compiler/Workspace.ff +88 -88
- package/core/.firefly/include/package-lock.json +394 -394
- package/core/.firefly/include/package.json +5 -5
- package/core/.firefly/include/prepare.sh +1 -1
- package/core/.firefly/package.ff +2 -2
- package/core/Array.ff +265 -265
- package/core/Atomic.ff +64 -64
- package/core/Box.ff +7 -7
- package/core/BrowserSystem.ff +40 -40
- package/core/BuildSystem.ff +148 -148
- package/core/Crypto.ff +96 -96
- package/core/Equal.ff +36 -36
- package/core/HttpClient.ff +87 -87
- package/core/JsSystem.ff +69 -69
- package/core/Json.ff +434 -434
- package/core/List.ff +486 -486
- package/core/Lock.ff +144 -144
- package/core/NodeSystem.ff +195 -189
- package/core/Ordering.ff +161 -161
- package/core/Path.ff +401 -401
- package/core/Random.ff +134 -134
- package/core/RbMap.ff +216 -216
- package/core/Show.ff +43 -43
- package/core/SourceLocation.ff +68 -68
- package/core/Task.ff +141 -141
- package/experimental/benchmarks/ListGrab.ff +23 -23
- package/experimental/benchmarks/ListGrab.java +55 -55
- package/experimental/benchmarks/Pyrotek45.ff +30 -30
- package/experimental/benchmarks/Pyrotek45.java +64 -64
- package/experimental/bidirectional/Bidi.ff +88 -88
- package/experimental/random/Index.ff +53 -53
- package/experimental/random/Process.ff +120 -120
- package/experimental/random/Scrape.ff +51 -51
- package/experimental/random/Symbols.ff +73 -73
- package/experimental/random/Tensor.ff +52 -52
- package/experimental/random/Units.ff +36 -36
- package/experimental/s3/S3TestAuthorizationHeader.ff +38 -38
- package/experimental/s3/S3TestPut.ff +15 -15
- package/experimental/tests/TestJson.ff +26 -26
- package/firefly.sh +0 -0
- package/fireflysite/Main.ff +13 -13
- package/lsp/.firefly/package.ff +1 -1
- package/lsp/CompletionHandler.ff +808 -808
- package/lsp/Handler.ff +714 -714
- package/lsp/HoverHandler.ff +79 -79
- package/lsp/LanguageServer.ff +272 -272
- package/lsp/SignatureHelpHandler.ff +55 -55
- package/lsp/SymbolHandler.ff +181 -181
- package/lsp/TestReferences.ff +16 -16
- package/lsp/TestReferencesCase.ff +7 -7
- package/lsp/stderr.txt +1 -1
- package/lsp/stdin.txt +10 -10
- package/lsp/stdout.txt +40 -40
- package/lux/.firefly/package.ff +1 -1
- package/lux/Css.ff +648 -648
- package/lux/CssTest.ff +48 -48
- package/lux/Lux.ff +487 -487
- package/lux/LuxEvent.ff +116 -116
- package/lux/Main.ff +128 -128
- package/lux/Main2.ff +144 -144
- package/output/js/ff/compiler/Builder.mjs +43 -43
- package/output/js/ff/compiler/Dependencies.mjs +3 -3
- package/output/js/ff/core/Array.mjs +59 -59
- package/output/js/ff/core/Atomic.mjs +36 -36
- package/output/js/ff/core/BrowserSystem.mjs +11 -11
- package/output/js/ff/core/BuildSystem.mjs +30 -30
- package/output/js/ff/core/Crypto.mjs +40 -40
- package/output/js/ff/core/HttpClient.mjs +24 -24
- package/output/js/ff/core/Json.mjs +147 -147
- package/output/js/ff/core/List.mjs +50 -50
- package/output/js/ff/core/Lock.mjs +97 -97
- package/output/js/ff/core/NodeSystem.mjs +83 -77
- package/output/js/ff/core/Ordering.mjs +8 -8
- package/output/js/ff/core/Path.mjs +231 -231
- package/output/js/ff/core/Random.mjs +56 -56
- package/output/js/ff/core/Task.mjs +31 -31
- package/package.json +1 -1
- package/rpc/.firefly/package.ff +1 -1
- package/rpc/Rpc.ff +69 -69
- package/s3/.firefly/package.ff +1 -1
- package/s3/S3.ff +90 -90
- package/unsafejs/UnsafeJs.ff +19 -19
- package/vscode/LICENSE.txt +21 -21
- package/vscode/Prepublish.ff +15 -15
- package/vscode/README.md +16 -16
- package/vscode/client/package.json +22 -22
- package/vscode/client/src/extension.ts +104 -104
- package/vscode/icons/firefly-icon.svg +10 -10
- package/vscode/language-configuration.json +61 -61
- package/vscode/package-lock.json +3623 -3623
- package/vscode/package.json +1 -1
- package/vscode/snippets.json +241 -241
- package/webserver/.firefly/include/package-lock.json +16 -16
- package/webserver/.firefly/include/package.json +5 -5
- package/webserver/.firefly/package.ff +2 -2
- package/webserver/WebServer.ff +685 -685
- package/websocket/.firefly/package.ff +1 -1
- package/websocket/WebSocket.ff +131 -131
|
@@ -110,36 +110,36 @@ return ff_core_Random.seedFloat_(seed_)
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
export function seedBuffer_(buffer_) {
|
|
113
|
-
|
|
114
|
-
var n = 0xefc8249d;
|
|
115
|
-
function mash(data) {
|
|
116
|
-
for(var i = 0; i < data.byteLength; i++) {
|
|
117
|
-
n += data.getUint8(i);
|
|
118
|
-
var h = 0.02519603282416938 * n;
|
|
119
|
-
n = h >>> 0;
|
|
120
|
-
h -= n;
|
|
121
|
-
h *= n;
|
|
122
|
-
n = h >>> 0;
|
|
123
|
-
h -= n;
|
|
124
|
-
n += h * 0x100000000; // 2^32
|
|
125
|
-
}
|
|
126
|
-
return (n >>> 0) * 2.3283064365386963e-10; // 2^-32
|
|
127
|
-
}
|
|
128
|
-
var space = new DataView(new Uint8Array([32]).buffer);
|
|
129
|
-
var r = {
|
|
130
|
-
s0: mash(space),
|
|
131
|
-
s1: mash(space),
|
|
132
|
-
s2: mash(space),
|
|
133
|
-
c: 1,
|
|
134
|
-
spareGauss: NaN
|
|
135
|
-
};
|
|
136
|
-
r.s0 -= mash(buffer_);
|
|
137
|
-
if(r.s0 < 0) r.s0 += 1;
|
|
138
|
-
r.s1 -= mash(buffer_);
|
|
139
|
-
if(r.s1 < 0) r.s1 += 1;
|
|
140
|
-
r.s2 -= mash(buffer_);
|
|
141
|
-
if(r.s2 < 0) r.s2 += 1;
|
|
142
|
-
return r;
|
|
113
|
+
|
|
114
|
+
var n = 0xefc8249d;
|
|
115
|
+
function mash(data) {
|
|
116
|
+
for(var i = 0; i < data.byteLength; i++) {
|
|
117
|
+
n += data.getUint8(i);
|
|
118
|
+
var h = 0.02519603282416938 * n;
|
|
119
|
+
n = h >>> 0;
|
|
120
|
+
h -= n;
|
|
121
|
+
h *= n;
|
|
122
|
+
n = h >>> 0;
|
|
123
|
+
h -= n;
|
|
124
|
+
n += h * 0x100000000; // 2^32
|
|
125
|
+
}
|
|
126
|
+
return (n >>> 0) * 2.3283064365386963e-10; // 2^-32
|
|
127
|
+
}
|
|
128
|
+
var space = new DataView(new Uint8Array([32]).buffer);
|
|
129
|
+
var r = {
|
|
130
|
+
s0: mash(space),
|
|
131
|
+
s1: mash(space),
|
|
132
|
+
s2: mash(space),
|
|
133
|
+
c: 1,
|
|
134
|
+
spareGauss: NaN
|
|
135
|
+
};
|
|
136
|
+
r.s0 -= mash(buffer_);
|
|
137
|
+
if(r.s0 < 0) r.s0 += 1;
|
|
138
|
+
r.s1 -= mash(buffer_);
|
|
139
|
+
if(r.s1 < 0) r.s1 += 1;
|
|
140
|
+
r.s2 -= mash(buffer_);
|
|
141
|
+
if(r.s2 < 0) r.s2 += 1;
|
|
142
|
+
return r;
|
|
143
143
|
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -162,24 +162,24 @@ throw new Error('Function seedBuffer is missing on this target in async context.
|
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
export function Random_copy(self_) {
|
|
165
|
-
|
|
166
|
-
return {...self_};
|
|
165
|
+
|
|
166
|
+
return {...self_};
|
|
167
167
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
export function Random_nextInt(self_, from_, until_) {
|
|
171
|
-
|
|
172
|
-
return Random_nextFloat(self_, from_, until_) | 0;
|
|
171
|
+
|
|
172
|
+
return Random_nextFloat(self_, from_, until_) | 0;
|
|
173
173
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
export function Random_nextFloat(self_, from_, until_) {
|
|
177
|
-
|
|
178
|
-
var t = 2091639 * self_.s0 + self_.c * 2.3283064365386963e-10; // 2^-32
|
|
179
|
-
self_.s0 = self_.s1;
|
|
180
|
-
self_.s1 = self_.s2;
|
|
181
|
-
var uniform = self_.s2 = t - (self_.c = t | 0);
|
|
182
|
-
return from_ + uniform * (until_ - from_);
|
|
177
|
+
|
|
178
|
+
var t = 2091639 * self_.s0 + self_.c * 2.3283064365386963e-10; // 2^-32
|
|
179
|
+
self_.s0 = self_.s1;
|
|
180
|
+
self_.s1 = self_.s2;
|
|
181
|
+
var uniform = self_.s2 = t - (self_.c = t | 0);
|
|
182
|
+
return from_ + uniform * (until_ - from_);
|
|
183
183
|
|
|
184
184
|
}
|
|
185
185
|
|
|
@@ -194,22 +194,22 @@ ff_core_Buffer.Buffer_setUint8(buffer_, i_, ff_core_Random.Random_nextInt(self_,
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
export function Random_nextGauss(self_, mean_, standardDeviation_) {
|
|
197
|
-
|
|
198
|
-
if(!isNaN(self_.spareGauss)) {
|
|
199
|
-
const result = self_.spareGauss * standardDeviation_ + mean_;
|
|
200
|
-
self_.spareGauss = NaN;
|
|
201
|
-
return result;
|
|
202
|
-
} else {
|
|
203
|
-
let u = 0.5, v = 0.5, s = 0.5;
|
|
204
|
-
do {
|
|
205
|
-
u = Random_nextFloat(self_, 0.0, 1.0) * 2 - 1;
|
|
206
|
-
v = Random_nextFloat(self_, 0.0, 1.0) * 2 - 1;
|
|
207
|
-
s = u * u + v * v;
|
|
208
|
-
} while(s >= 1 || s == 0);
|
|
209
|
-
s = Math.sqrt(-2.0 * Math.log(s) / s);
|
|
210
|
-
self_.spareGauss = v * s;
|
|
211
|
-
return mean_ + standardDeviation_ * u * s;
|
|
212
|
-
}
|
|
197
|
+
|
|
198
|
+
if(!isNaN(self_.spareGauss)) {
|
|
199
|
+
const result = self_.spareGauss * standardDeviation_ + mean_;
|
|
200
|
+
self_.spareGauss = NaN;
|
|
201
|
+
return result;
|
|
202
|
+
} else {
|
|
203
|
+
let u = 0.5, v = 0.5, s = 0.5;
|
|
204
|
+
do {
|
|
205
|
+
u = Random_nextFloat(self_, 0.0, 1.0) * 2 - 1;
|
|
206
|
+
v = Random_nextFloat(self_, 0.0, 1.0) * 2 - 1;
|
|
207
|
+
s = u * u + v * v;
|
|
208
|
+
} while(s >= 1 || s == 0);
|
|
209
|
+
s = Math.sqrt(-2.0 * Math.log(s) / s);
|
|
210
|
+
self_.spareGauss = v * s;
|
|
211
|
+
return mean_ + standardDeviation_ * u * s;
|
|
212
|
+
}
|
|
213
213
|
|
|
214
214
|
}
|
|
215
215
|
|
|
@@ -100,39 +100,39 @@ import * as ff_core_Unit from "../../ff/core/Unit.mjs"
|
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
export function Task_spawn(self_, body_) {
|
|
103
|
-
|
|
104
|
-
ff_core_Task.Task_throwIfAborted(self_)
|
|
105
|
-
const task = {controller: new AbortController(), subtasks: new Set(), started: performance.now() * 0.001}
|
|
106
|
-
self_.subtasks.add(task)
|
|
107
|
-
task.promise = Promise.resolve(task).then(async () => {
|
|
108
|
-
try {
|
|
109
|
-
await body_(task, task)
|
|
110
|
-
} catch(e) {
|
|
111
|
-
await ff_core_Task.Task_abort$(self_)
|
|
112
|
-
throw e
|
|
113
|
-
} finally {
|
|
114
|
-
for(const subtask of task.subtasks) subtask.controller.abort()
|
|
115
|
-
await Promise.allSettled([...task.subtasks].map(subtask => subtask.promise))
|
|
116
|
-
self_.subtasks.delete(task)
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
return task
|
|
103
|
+
|
|
104
|
+
ff_core_Task.Task_throwIfAborted(self_)
|
|
105
|
+
const task = {controller: new AbortController(), subtasks: new Set(), started: performance.now() * 0.001}
|
|
106
|
+
self_.subtasks.add(task)
|
|
107
|
+
task.promise = Promise.resolve(task).then(async () => {
|
|
108
|
+
try {
|
|
109
|
+
await body_(task, task)
|
|
110
|
+
} catch(e) {
|
|
111
|
+
await ff_core_Task.Task_abort$(self_)
|
|
112
|
+
throw e
|
|
113
|
+
} finally {
|
|
114
|
+
for(const subtask of task.subtasks) subtask.controller.abort()
|
|
115
|
+
await Promise.allSettled([...task.subtasks].map(subtask => subtask.promise))
|
|
116
|
+
self_.subtasks.delete(task)
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
return task
|
|
120
120
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
export function Task_throwIfAborted(self_) {
|
|
124
|
-
|
|
125
|
-
if(self_.controller.signal.aborted) {
|
|
126
|
-
const signal = self_.controller.signal
|
|
127
|
-
self_.controller = new AbortController()
|
|
128
|
-
signal.throwIfAborted()
|
|
129
|
-
}
|
|
124
|
+
|
|
125
|
+
if(self_.controller.signal.aborted) {
|
|
126
|
+
const signal = self_.controller.signal
|
|
127
|
+
self_.controller = new AbortController()
|
|
128
|
+
signal.throwIfAborted()
|
|
129
|
+
}
|
|
130
130
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
export function Task_abort(self_) {
|
|
134
|
-
|
|
135
|
-
self_.controller.abort()
|
|
134
|
+
|
|
135
|
+
self_.controller.abort()
|
|
136
136
|
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -161,20 +161,20 @@ return ff_core_Pair.Pair(result_, duration_)
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
export async function Task_spawn$(self_, body_, $task) {
|
|
164
|
-
|
|
165
|
-
return ff_core_Task.Task_spawn(self_, body_)
|
|
164
|
+
|
|
165
|
+
return ff_core_Task.Task_spawn(self_, body_)
|
|
166
166
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
export async function Task_throwIfAborted$(self_, $task) {
|
|
170
|
-
|
|
171
|
-
ff_core_Task.Task_throwIfAborted(self_)
|
|
170
|
+
|
|
171
|
+
ff_core_Task.Task_throwIfAborted(self_)
|
|
172
172
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
export async function Task_abort$(self_, $task) {
|
|
176
|
-
|
|
177
|
-
self_.controller.abort()
|
|
176
|
+
|
|
177
|
+
self_.controller.abort()
|
|
178
178
|
|
|
179
179
|
}
|
|
180
180
|
|
package/package.json
CHANGED
package/rpc/.firefly/package.ff
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
package ff:rpc:0.0.0
|
|
1
|
+
package ff:rpc:0.0.0
|
package/rpc/Rpc.ff
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
trait I: Rpc[O] {}
|
|
2
|
-
|
|
3
|
-
capability RpcServer[I, O, C](
|
|
4
|
-
handlers: StringMap[(C, I) => O]
|
|
5
|
-
)
|
|
6
|
-
|
|
7
|
-
newServer[I, O, C](): RpcServer[I, O, C] {
|
|
8
|
-
RpcServer(StringMap.new())
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
extend self[I, O, C]: RpcServer[I, O, C] {
|
|
12
|
-
handle(name: String, context: C, input: I): Option[O] {
|
|
13
|
-
self.handlers.get(name).map {handler =>
|
|
14
|
-
handler(context, input)
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
addCustom(
|
|
19
|
-
handler: (C, I) => O
|
|
20
|
-
): Unit {
|
|
21
|
-
let name = "TODO"
|
|
22
|
-
self.handlers.set(name) {context, input =>
|
|
23
|
-
handler(context, input)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
extend self[C]: RpcServer[Buffer, Buffer, C] {
|
|
29
|
-
add[I: Rpc[O]: HasAnyTag: Serializable, O: Serializable](
|
|
30
|
-
handler: (C, I) => O
|
|
31
|
-
): Unit {
|
|
32
|
-
let name = Any.anyTag[I]().show()
|
|
33
|
-
self.handlers.set(name) {context, message =>
|
|
34
|
-
let input = Serializable.deserialize(message)
|
|
35
|
-
let output = handler(context, input)
|
|
36
|
-
Serializable.serialize(output)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
capability RpcClient(
|
|
42
|
-
binaryCall: (String, Buffer) => Buffer
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
extend self: RpcClient {
|
|
46
|
-
call[I: Rpc[O]: HasAnyTag: Serializable, O: Serializable](
|
|
47
|
-
message: I
|
|
48
|
-
): O {
|
|
49
|
-
let name = Any.anyTag[I]().show()
|
|
50
|
-
let input = Serializable.serialize(message)
|
|
51
|
-
let response = self.binaryCall(name, input)
|
|
52
|
-
Serializable.deserialize(response)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
newClient(
|
|
57
|
-
httpClient: HttpClient
|
|
58
|
-
prefix: String
|
|
59
|
-
method: String = "POST"
|
|
60
|
-
): RpcClient {
|
|
61
|
-
RpcClient {name, buffer =>
|
|
62
|
-
let response = httpClient.fetch(
|
|
63
|
-
url = prefix + name,
|
|
64
|
-
method = method,
|
|
65
|
-
body = Some(HttpClient.bodyBuffer(buffer))
|
|
66
|
-
)
|
|
67
|
-
response.readBuffer()
|
|
68
|
-
}
|
|
69
|
-
}
|
|
1
|
+
trait I: Rpc[O] {}
|
|
2
|
+
|
|
3
|
+
capability RpcServer[I, O, C](
|
|
4
|
+
handlers: StringMap[(C, I) => O]
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
newServer[I, O, C](): RpcServer[I, O, C] {
|
|
8
|
+
RpcServer(StringMap.new())
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
extend self[I, O, C]: RpcServer[I, O, C] {
|
|
12
|
+
handle(name: String, context: C, input: I): Option[O] {
|
|
13
|
+
self.handlers.get(name).map {handler =>
|
|
14
|
+
handler(context, input)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
addCustom(
|
|
19
|
+
handler: (C, I) => O
|
|
20
|
+
): Unit {
|
|
21
|
+
let name = "TODO"
|
|
22
|
+
self.handlers.set(name) {context, input =>
|
|
23
|
+
handler(context, input)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
extend self[C]: RpcServer[Buffer, Buffer, C] {
|
|
29
|
+
add[I: Rpc[O]: HasAnyTag: Serializable, O: Serializable](
|
|
30
|
+
handler: (C, I) => O
|
|
31
|
+
): Unit {
|
|
32
|
+
let name = Any.anyTag[I]().show()
|
|
33
|
+
self.handlers.set(name) {context, message =>
|
|
34
|
+
let input = Serializable.deserialize(message)
|
|
35
|
+
let output = handler(context, input)
|
|
36
|
+
Serializable.serialize(output)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
capability RpcClient(
|
|
42
|
+
binaryCall: (String, Buffer) => Buffer
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
extend self: RpcClient {
|
|
46
|
+
call[I: Rpc[O]: HasAnyTag: Serializable, O: Serializable](
|
|
47
|
+
message: I
|
|
48
|
+
): O {
|
|
49
|
+
let name = Any.anyTag[I]().show()
|
|
50
|
+
let input = Serializable.serialize(message)
|
|
51
|
+
let response = self.binaryCall(name, input)
|
|
52
|
+
Serializable.deserialize(response)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
newClient(
|
|
57
|
+
httpClient: HttpClient
|
|
58
|
+
prefix: String
|
|
59
|
+
method: String = "POST"
|
|
60
|
+
): RpcClient {
|
|
61
|
+
RpcClient {name, buffer =>
|
|
62
|
+
let response = httpClient.fetch(
|
|
63
|
+
url = prefix + name,
|
|
64
|
+
method = method,
|
|
65
|
+
body = Some(HttpClient.bodyBuffer(buffer))
|
|
66
|
+
)
|
|
67
|
+
response.readBuffer()
|
|
68
|
+
}
|
|
69
|
+
}
|
package/s3/.firefly/package.ff
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
package ff:s3:0.0.0
|
|
1
|
+
package ff:s3:0.0.0
|
package/s3/S3.ff
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
put(
|
|
2
|
-
system: NodeSystem
|
|
3
|
-
accessKeyId: String
|
|
4
|
-
secretAccessKey: String
|
|
5
|
-
region: String
|
|
6
|
-
bucket: String
|
|
7
|
-
objectKey: String
|
|
8
|
-
body: Buffer
|
|
9
|
-
headers: List[Pair[String, String]]
|
|
10
|
-
): Unit {
|
|
11
|
-
let now = system.mainTask().now()
|
|
12
|
-
let amzDate = toIsoString(now)
|
|
13
|
-
let contentHash = system.crypto().sha256(body).toHex()
|
|
14
|
-
let host = bucket + ".s3.amazonaws.com"
|
|
15
|
-
let encodedKey = encode(objectKey)
|
|
16
|
-
let canonicalHeaders = [
|
|
17
|
-
Pair("host", host)
|
|
18
|
-
Pair("x-amz-date", amzDate)
|
|
19
|
-
Pair("x-amz-content-sha256", contentHash)
|
|
20
|
-
...headers
|
|
21
|
-
]
|
|
22
|
-
let authenticationHeader = makeS3AuthorizationHeader(system, accessKeyId, secretAccessKey, region, bucket, encodedKey, body, canonicalHeaders, amzDate)
|
|
23
|
-
let allHeaders = [...canonicalHeaders, Pair("Authorization", authenticationHeader)]
|
|
24
|
-
|
|
25
|
-
let url = "https://" + host + "/" + encodedKey
|
|
26
|
-
system.httpClient().fetch(url, method = "PUT", headers = allHeaders, body = Some(HttpClient.bodyBuffer(body)), throw = True)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
makeS3AuthorizationHeader(
|
|
30
|
-
system: NodeSystem
|
|
31
|
-
accessKeyId: String
|
|
32
|
-
secretAccessKey: String
|
|
33
|
-
region: String
|
|
34
|
-
bucket: String
|
|
35
|
-
encodedKey: String
|
|
36
|
-
body: Buffer
|
|
37
|
-
canonicalHeaders: List[Pair[String, String]]
|
|
38
|
-
amzDate: String
|
|
39
|
-
): String {
|
|
40
|
-
// CanonicalRequest
|
|
41
|
-
let canonicalQuerystring = "";
|
|
42
|
-
let contentHash = system.crypto().sha256(body).toHex()
|
|
43
|
-
let headers = canonicalHeaders.map {_.mapFirst {_.lower()}.mapSecond {_.trim()}}.sort()
|
|
44
|
-
let signedHeaders = headers.map {_.first}.join(";")
|
|
45
|
-
let canonicalRequest = [
|
|
46
|
-
"PUT"
|
|
47
|
-
"/" + encodedKey
|
|
48
|
-
canonicalQuerystring
|
|
49
|
-
...headers.map {p => p.first + ":" + p.second}
|
|
50
|
-
""
|
|
51
|
-
signedHeaders
|
|
52
|
-
contentHash
|
|
53
|
-
].join("\n")
|
|
54
|
-
|
|
55
|
-
// StringToSign
|
|
56
|
-
let scopeDate = amzDate.slice(0, 8) // YYYYMMDD
|
|
57
|
-
let credentialScope = [scopeDate, region, "s3", "aws4_request"].join("/")
|
|
58
|
-
let algorithm = "AWS4-HMAC-SHA256"
|
|
59
|
-
let stringToSign = [
|
|
60
|
-
algorithm
|
|
61
|
-
amzDate
|
|
62
|
-
credentialScope
|
|
63
|
-
system.crypto().sha256(canonicalRequest.toBuffer()).toHex()
|
|
64
|
-
].join("\n")
|
|
65
|
-
|
|
66
|
-
function hmacSha256(key: Buffer, message: String): Buffer {
|
|
67
|
-
system.crypto().hmacSha256(key, message.toBuffer())
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Signature
|
|
71
|
-
let signingKey = hmacSha256(hmacSha256(hmacSha256(hmacSha256(("AWS4" + secretAccessKey).toBuffer(), scopeDate), region), "s3"), "aws4_request")
|
|
72
|
-
let signature = hmacSha256(signingKey, stringToSign).toHex()
|
|
73
|
-
|
|
74
|
-
algorithm + " Credential=" + accessKeyId + "/" + credentialScope + ",SignedHeaders=" + signedHeaders + ",Signature=" + signature
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
toIsoString(instant: Instant): String
|
|
78
|
-
target js sync """
|
|
79
|
-
const d = new Date(instant_ * 1000);
|
|
80
|
-
return d.toISOString().replaceAll(/[-:]|[.].../g, "");
|
|
81
|
-
"""
|
|
82
|
-
|
|
83
|
-
encodeURIComponent(text: String): String
|
|
84
|
-
target js sync """
|
|
85
|
-
return encodeURIComponent(text_);
|
|
86
|
-
"""
|
|
87
|
-
|
|
88
|
-
encode(text: String): String {
|
|
89
|
-
text.split('/').map {encodeURIComponent(_)}.join("/")
|
|
90
|
-
}
|
|
1
|
+
put(
|
|
2
|
+
system: NodeSystem
|
|
3
|
+
accessKeyId: String
|
|
4
|
+
secretAccessKey: String
|
|
5
|
+
region: String
|
|
6
|
+
bucket: String
|
|
7
|
+
objectKey: String
|
|
8
|
+
body: Buffer
|
|
9
|
+
headers: List[Pair[String, String]]
|
|
10
|
+
): Unit {
|
|
11
|
+
let now = system.mainTask().now()
|
|
12
|
+
let amzDate = toIsoString(now)
|
|
13
|
+
let contentHash = system.crypto().sha256(body).toHex()
|
|
14
|
+
let host = bucket + ".s3.amazonaws.com"
|
|
15
|
+
let encodedKey = encode(objectKey)
|
|
16
|
+
let canonicalHeaders = [
|
|
17
|
+
Pair("host", host)
|
|
18
|
+
Pair("x-amz-date", amzDate)
|
|
19
|
+
Pair("x-amz-content-sha256", contentHash)
|
|
20
|
+
...headers
|
|
21
|
+
]
|
|
22
|
+
let authenticationHeader = makeS3AuthorizationHeader(system, accessKeyId, secretAccessKey, region, bucket, encodedKey, body, canonicalHeaders, amzDate)
|
|
23
|
+
let allHeaders = [...canonicalHeaders, Pair("Authorization", authenticationHeader)]
|
|
24
|
+
|
|
25
|
+
let url = "https://" + host + "/" + encodedKey
|
|
26
|
+
system.httpClient().fetch(url, method = "PUT", headers = allHeaders, body = Some(HttpClient.bodyBuffer(body)), throw = True)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
makeS3AuthorizationHeader(
|
|
30
|
+
system: NodeSystem
|
|
31
|
+
accessKeyId: String
|
|
32
|
+
secretAccessKey: String
|
|
33
|
+
region: String
|
|
34
|
+
bucket: String
|
|
35
|
+
encodedKey: String
|
|
36
|
+
body: Buffer
|
|
37
|
+
canonicalHeaders: List[Pair[String, String]]
|
|
38
|
+
amzDate: String
|
|
39
|
+
): String {
|
|
40
|
+
// CanonicalRequest
|
|
41
|
+
let canonicalQuerystring = "";
|
|
42
|
+
let contentHash = system.crypto().sha256(body).toHex()
|
|
43
|
+
let headers = canonicalHeaders.map {_.mapFirst {_.lower()}.mapSecond {_.trim()}}.sort()
|
|
44
|
+
let signedHeaders = headers.map {_.first}.join(";")
|
|
45
|
+
let canonicalRequest = [
|
|
46
|
+
"PUT"
|
|
47
|
+
"/" + encodedKey
|
|
48
|
+
canonicalQuerystring
|
|
49
|
+
...headers.map {p => p.first + ":" + p.second}
|
|
50
|
+
""
|
|
51
|
+
signedHeaders
|
|
52
|
+
contentHash
|
|
53
|
+
].join("\n")
|
|
54
|
+
|
|
55
|
+
// StringToSign
|
|
56
|
+
let scopeDate = amzDate.slice(0, 8) // YYYYMMDD
|
|
57
|
+
let credentialScope = [scopeDate, region, "s3", "aws4_request"].join("/")
|
|
58
|
+
let algorithm = "AWS4-HMAC-SHA256"
|
|
59
|
+
let stringToSign = [
|
|
60
|
+
algorithm
|
|
61
|
+
amzDate
|
|
62
|
+
credentialScope
|
|
63
|
+
system.crypto().sha256(canonicalRequest.toBuffer()).toHex()
|
|
64
|
+
].join("\n")
|
|
65
|
+
|
|
66
|
+
function hmacSha256(key: Buffer, message: String): Buffer {
|
|
67
|
+
system.crypto().hmacSha256(key, message.toBuffer())
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Signature
|
|
71
|
+
let signingKey = hmacSha256(hmacSha256(hmacSha256(hmacSha256(("AWS4" + secretAccessKey).toBuffer(), scopeDate), region), "s3"), "aws4_request")
|
|
72
|
+
let signature = hmacSha256(signingKey, stringToSign).toHex()
|
|
73
|
+
|
|
74
|
+
algorithm + " Credential=" + accessKeyId + "/" + credentialScope + ",SignedHeaders=" + signedHeaders + ",Signature=" + signature
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
toIsoString(instant: Instant): String
|
|
78
|
+
target js sync """
|
|
79
|
+
const d = new Date(instant_ * 1000);
|
|
80
|
+
return d.toISOString().replaceAll(/[-:]|[.].../g, "");
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
encodeURIComponent(text: String): String
|
|
84
|
+
target js sync """
|
|
85
|
+
return encodeURIComponent(text_);
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
encode(text: String): String {
|
|
89
|
+
text.split('/').map {encodeURIComponent(_)}.join("/")
|
|
90
|
+
}
|
package/unsafejs/UnsafeJs.ff
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
jsSystem(): JsSystem
|
|
2
|
-
target js async "return typeof globalThis !== 'undefined' ? globalThis : window"
|
|
3
|
-
target js sync "return typeof globalThis !== 'undefined' ? globalThis : window"
|
|
4
|
-
|
|
5
|
-
import(module: String): JsValue
|
|
6
|
-
// Replaced by the compiler ~ hoisted top level import - dynamic imports not currently supported
|
|
7
|
-
target js sync "throw Error('Dynamic JS imports are not currently supported.')"
|
|
8
|
-
|
|
9
|
-
await[T](body: () => T): T // This is never actually called async, but will be rewitten by the compiler
|
|
10
|
-
// Replaced by the compiler
|
|
11
|
-
target js sync "return body_()"
|
|
12
|
-
|
|
13
|
-
throwIfCancelled(): Unit
|
|
14
|
-
// Replaced by the compiler
|
|
15
|
-
target js sync ""
|
|
16
|
-
|
|
17
|
-
cancelled(): Bool
|
|
18
|
-
// Replaced by the compiler
|
|
19
|
-
target js sync "return false"
|
|
1
|
+
jsSystem(): JsSystem
|
|
2
|
+
target js async "return typeof globalThis !== 'undefined' ? globalThis : window"
|
|
3
|
+
target js sync "return typeof globalThis !== 'undefined' ? globalThis : window"
|
|
4
|
+
|
|
5
|
+
import(module: String): JsValue
|
|
6
|
+
// Replaced by the compiler ~ hoisted top level import - dynamic imports not currently supported
|
|
7
|
+
target js sync "throw Error('Dynamic JS imports are not currently supported.')"
|
|
8
|
+
|
|
9
|
+
await[T](body: () => T): T // This is never actually called async, but will be rewitten by the compiler
|
|
10
|
+
// Replaced by the compiler
|
|
11
|
+
target js sync "return body_()"
|
|
12
|
+
|
|
13
|
+
throwIfCancelled(): Unit
|
|
14
|
+
// Replaced by the compiler
|
|
15
|
+
target js sync ""
|
|
16
|
+
|
|
17
|
+
cancelled(): Bool
|
|
18
|
+
// Replaced by the compiler
|
|
19
|
+
target js sync "return false"
|
package/vscode/LICENSE.txt
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020-2023 Joakim Ahnfelt-Rønne, Michael Werk Ravnsmed
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020-2023 Joakim Ahnfelt-Rønne, Michael Werk Ravnsmed
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|