@dreamboard-games/sdk 0.2.0 → 0.2.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/dist/{ThemeProvider-fy0_QzgO.d.ts → ThemeProvider-BBMVT3KG.d.ts} +1 -1
- package/dist/attributes-BeRyboMS.d.ts +279 -0
- package/dist/browser-interaction.d.ts +708 -0
- package/dist/browser-interaction.js +106 -0
- package/dist/browser-interaction.js.map +1 -0
- package/dist/{bundle-TIZcw8LB.d.ts → bundle-CDd5FKeD.d.ts} +3 -1
- package/dist/{chunk-U5C6BONG.js → chunk-326PGVAA.js} +2 -2
- package/dist/{chunk-VFTAA4WO.js → chunk-MKXPVOUT.js} +4 -2
- package/dist/chunk-MKXPVOUT.js.map +1 -0
- package/dist/{chunk-GKKBPPSW.js → chunk-MZNVHMJ5.js} +4 -4
- package/dist/{chunk-KAELH4KC.js → chunk-NKCRKGR2.js} +2 -2
- package/dist/{chunk-WN74KVNY.js → chunk-PEI3FIL2.js} +2 -2
- package/dist/chunk-PEI3FIL2.js.map +1 -0
- package/dist/chunk-QLG6VEMW.js +1691 -0
- package/dist/chunk-QLG6VEMW.js.map +1 -0
- package/dist/{chunk-WYPQ3GG5.js → chunk-WG4JQL3S.js} +4 -1
- package/dist/{chunk-WYPQ3GG5.js.map → chunk-WG4JQL3S.js.map} +1 -1
- package/dist/{chunk-7YAHLYBR.js → chunk-XV6D3ET4.js} +8 -4
- package/dist/{chunk-7YAHLYBR.js.map → chunk-XV6D3ET4.js.map} +1 -1
- package/dist/{chunk-TDSWKVZ4.js → chunk-ZABVH7AO.js} +1236 -17
- package/dist/chunk-ZABVH7AO.js.map +1 -0
- package/dist/{components-D5ZRE2Hl.d.ts → components-BoiVSYqx.d.ts} +1 -1
- package/dist/generated/runtime/primitives.d.ts +5 -4
- package/dist/generated/runtime/primitives.js +4 -3
- package/dist/generated/runtime-api.d.ts +1 -1
- package/dist/generated/runtime.d.ts +5 -4
- package/dist/generated/runtime.js +7 -6
- package/dist/generated/workspace-contract.d.ts +5 -4
- package/dist/generated/workspace-contract.js +6 -5
- package/dist/{hex-board-view-D_07hO6O.d.ts → hex-board-view-1iAyJRFn.d.ts} +1 -0
- package/dist/index.js +1 -1
- package/dist/infrastructure/reducer-bundle-abi.d.ts +113 -113
- package/dist/infrastructure/reducer-bundle-abi.js +1 -1
- package/dist/package-set.d.ts +2 -2
- package/dist/package-set.js +1 -1
- package/dist/reducer.d.ts +1 -1
- package/dist/reducer.js +305 -12
- package/dist/reducer.js.map +1 -1
- package/dist/runtime/primitives.d.ts +6 -5
- package/dist/runtime/primitives.js +4 -3
- package/dist/runtime/workspace-contract.d.ts +6 -5
- package/dist/runtime/workspace-contract.js +6 -5
- package/dist/{runtime-api-DWxvTr-O.d.ts → runtime-api-CPLm_XDG.d.ts} +6 -0
- package/dist/runtime.d.ts +5 -4
- package/dist/runtime.js +6 -5
- package/dist/testing.d.ts +2 -2
- package/dist/ui/components.d.ts +2 -2
- package/dist/ui/components.js +1 -1
- package/dist/{ui-contract-iQfTtUSL.d.ts → ui-contract-rzKBwOLC.d.ts} +5 -3
- package/dist/ui.d.ts +5 -5
- package/dist/ui.js +2 -2
- package/package.json +15 -9
- package/src/browser-interaction/attributes.ts +211 -0
- package/src/browser-interaction/canonical.ts +77 -0
- package/src/browser-interaction/constants.ts +77 -0
- package/src/browser-interaction/effects.ts +176 -0
- package/src/browser-interaction/index.ts +111 -0
- package/src/browser-interaction/normalize.ts +997 -0
- package/src/browser-interaction/registry.ts +70 -0
- package/src/browser-interaction/resolve.ts +596 -0
- package/src/browser-interaction/schemas.ts +152 -0
- package/src/browser-interaction/types.ts +304 -0
- package/src/browser-interaction.ts +1 -0
- package/src/generated/reducer-contract/wire.ts +1 -1
- package/src/generated/reducer-contract/zod.ts +3 -1
- package/src/package-set.ts +1 -1
- package/src/reducer/bundle/ingress-bundle.ts +1 -1
- package/src/reducer/bundle/trusted/interaction-types.ts +3 -0
- package/src/reducer/bundle/trusted/projection-builder.ts +337 -13
- package/src/reducer/ingress/input-codec.ts +1 -1
- package/src/reducer/ingress/session-codec.ts +1 -1
- package/src/runtime-internal/components/InteractionForm.tsx +345 -7
- package/src/runtime-internal/components/PluginRuntime.tsx +2 -0
- package/src/runtime-internal/components/board/target-layer.ts +2 -0
- package/src/runtime-internal/context/PluginStateContext.tsx +41 -0
- package/src/runtime-internal/hooks/useBoardInteractions.ts +73 -11
- package/src/runtime-internal/primitives/board.tsx +71 -0
- package/src/runtime-internal/primitives/interaction.tsx +160 -1
- package/src/runtime-internal/types/plugin-state.ts +6 -0
- package/src/runtime-internal/utils/browser-interaction-effects.ts +240 -0
- package/src/runtime-internal/utils/interaction-draft-digest.ts +252 -0
- package/src/runtime-internal/utils/semantic-projection-digest.ts +407 -0
- package/src/ui/components/board/HexGrid.tsx +3 -0
- package/src/ui/components/board/target-layer.ts +1 -0
- package/dist/chunk-TDSWKVZ4.js.map +0 -1
- package/dist/chunk-VFTAA4WO.js.map +0 -1
- package/dist/chunk-WN74KVNY.js.map +0 -1
- /package/dist/{chunk-U5C6BONG.js.map → chunk-326PGVAA.js.map} +0 -0
- /package/dist/{chunk-GKKBPPSW.js.map → chunk-MZNVHMJ5.js.map} +0 -0
- /package/dist/{chunk-KAELH4KC.js.map → chunk-NKCRKGR2.js.map} +0 -0
package/dist/package-set.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
declare const DREAMBOARD_SDK_VERSION = "0.2.
|
|
1
|
+
declare const DREAMBOARD_SDK_VERSION = "0.2.1-alpha.1";
|
|
2
2
|
declare const DREAMBOARD_SDK_PACKAGES: {
|
|
3
|
-
readonly "@dreamboard-games/sdk": "0.2.
|
|
3
|
+
readonly "@dreamboard-games/sdk": "0.2.1-alpha.1";
|
|
4
4
|
};
|
|
5
5
|
type DreamboardSdkPackageName = keyof typeof DREAMBOARD_SDK_PACKAGES;
|
|
6
6
|
type DreamboardSdkPackageSet = {
|
package/dist/package-set.js
CHANGED
package/dist/reducer.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { C as CardCollection, V as ViewCard } from './cards-Sl3b40Mv.js';
|
|
3
3
|
import { V as ViewSlotOccupant } from './slots-1GPGihk8.js';
|
|
4
|
-
import { R as ReducerBundleContract } from './bundle-
|
|
4
|
+
import { R as ReducerBundleContract } from './bundle-CDd5FKeD.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Opaque brand applied to a runtime player identifier.
|
package/dist/reducer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
REDUCER_CONTRACT_VERSION,
|
|
3
3
|
ReducerSessionStateSchema
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MKXPVOUT.js";
|
|
5
5
|
import "./chunk-PZ5AY32C.js";
|
|
6
6
|
|
|
7
7
|
// src/reducer/model/manifest.ts
|
|
@@ -6837,14 +6837,18 @@ function createProjectionBuilder(scope, interactions) {
|
|
|
6837
6837
|
const byRef = {};
|
|
6838
6838
|
const byHash = /* @__PURE__ */ new Map();
|
|
6839
6839
|
return {
|
|
6840
|
-
add(descriptor) {
|
|
6841
|
-
const
|
|
6840
|
+
add(descriptor, actorSeat) {
|
|
6841
|
+
const enriched = descriptorWithBrowserReplayDigests(
|
|
6842
|
+
descriptor,
|
|
6843
|
+
actorSeat
|
|
6844
|
+
);
|
|
6845
|
+
const fingerprint = stableStringify(enriched);
|
|
6842
6846
|
const existing = byHash.get(fingerprint);
|
|
6843
6847
|
if (existing) return existing;
|
|
6844
|
-
const base = typeof
|
|
6848
|
+
const base = typeof enriched.interactionId === "string" && enriched.interactionId.length > 0 ? enriched.interactionId : "interaction";
|
|
6845
6849
|
const ref = `${base}:${fnv1a64(fingerprint)}`;
|
|
6846
6850
|
byHash.set(fingerprint, ref);
|
|
6847
|
-
byRef[ref] =
|
|
6851
|
+
byRef[ref] = enriched;
|
|
6848
6852
|
return ref;
|
|
6849
6853
|
},
|
|
6850
6854
|
entries() {
|
|
@@ -6852,7 +6856,7 @@ function createProjectionBuilder(scope, interactions) {
|
|
|
6852
6856
|
}
|
|
6853
6857
|
};
|
|
6854
6858
|
}
|
|
6855
|
-
function resolveZoneHandlesFor(combinedState, playerId, projection, registry) {
|
|
6859
|
+
function resolveZoneHandlesFor(combinedState, playerId, actorSeat, projection, registry) {
|
|
6856
6860
|
const phaseName = combinedState.flow.currentPhase;
|
|
6857
6861
|
const zoneIds = new Set(scope.zonesForPhase(phaseName).map(String));
|
|
6858
6862
|
for (const [, interaction] of scope.interactionEntriesForPhase(phaseName)) {
|
|
@@ -6907,10 +6911,13 @@ function createProjectionBuilder(scope, interactions) {
|
|
|
6907
6911
|
continue;
|
|
6908
6912
|
}
|
|
6909
6913
|
perCard.push(
|
|
6910
|
-
registry.add(
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
+
registry.add(
|
|
6915
|
+
{
|
|
6916
|
+
...decision.descriptor,
|
|
6917
|
+
zoneId
|
|
6918
|
+
},
|
|
6919
|
+
actorSeat
|
|
6920
|
+
)
|
|
6914
6921
|
);
|
|
6915
6922
|
}
|
|
6916
6923
|
playableByCardId[cardId] = perCard;
|
|
@@ -6990,16 +6997,17 @@ function createProjectionBuilder(scope, interactions) {
|
|
|
6990
6997
|
});
|
|
6991
6998
|
const registry = createDescriptorRegistry();
|
|
6992
6999
|
const seats = {};
|
|
6993
|
-
for (const playerId of playerIds) {
|
|
7000
|
+
for (const [actorSeat, playerId] of playerIds.entries()) {
|
|
6994
7001
|
const availableInteractionRefs = interactions.resolveAvailableInteractionsFor(combinedState, playerId, {
|
|
6995
7002
|
projection
|
|
6996
|
-
}).map((descriptor) => registry.add(descriptor));
|
|
7003
|
+
}).map((descriptor) => registry.add(descriptor, actorSeat));
|
|
6997
7004
|
seats[playerId] = {
|
|
6998
7005
|
...projectionMode === "full" ? {
|
|
6999
7006
|
view: resolveViewFor(combinedState, playerId, viewId, projection),
|
|
7000
7007
|
zones: resolveZoneHandlesFor(
|
|
7001
7008
|
combinedState,
|
|
7002
7009
|
playerId,
|
|
7010
|
+
actorSeat,
|
|
7003
7011
|
projection,
|
|
7004
7012
|
registry
|
|
7005
7013
|
)
|
|
@@ -7036,6 +7044,126 @@ function createProjectionBuilder(scope, interactions) {
|
|
|
7036
7044
|
resolveZoneHandlesFor
|
|
7037
7045
|
};
|
|
7038
7046
|
}
|
|
7047
|
+
function descriptorWithBrowserReplayDigests(descriptor, actorSeat) {
|
|
7048
|
+
const descriptorDigestValue = descriptor.descriptorDigest ?? interactionDescriptorDigest(descriptor);
|
|
7049
|
+
return {
|
|
7050
|
+
...descriptor,
|
|
7051
|
+
descriptorDigest: descriptorDigestValue,
|
|
7052
|
+
actorSeat,
|
|
7053
|
+
draftDigest: descriptor.draftDigest ?? interactionDraftDigest({
|
|
7054
|
+
actorSeat,
|
|
7055
|
+
descriptor,
|
|
7056
|
+
descriptorDigest: descriptorDigestValue
|
|
7057
|
+
})
|
|
7058
|
+
};
|
|
7059
|
+
}
|
|
7060
|
+
function interactionDescriptorDigest(descriptor) {
|
|
7061
|
+
return hashJson({
|
|
7062
|
+
commitMode: descriptor.commit.mode,
|
|
7063
|
+
defaults: toDescriptorDigestJson(defaultsForDescriptor(descriptor)),
|
|
7064
|
+
inputKeys: descriptor.inputs.map((input) => input.key),
|
|
7065
|
+
inputs: descriptor.inputs.map((input) => ({
|
|
7066
|
+
key: input.key,
|
|
7067
|
+
kind: input.kind,
|
|
7068
|
+
domain: toDescriptorDigestJson(input.domain),
|
|
7069
|
+
defaultValue: input.defaultValue === void 0 ? null : toDescriptorDigestJson(input.defaultValue)
|
|
7070
|
+
})),
|
|
7071
|
+
interactionId: descriptor.interactionId,
|
|
7072
|
+
interactionKey: descriptor.interactionKey,
|
|
7073
|
+
stableIdentity: `${descriptor.interactionKey}:${descriptor.interactionId}`
|
|
7074
|
+
});
|
|
7075
|
+
}
|
|
7076
|
+
function interactionDraftDigest({
|
|
7077
|
+
actorSeat,
|
|
7078
|
+
descriptor,
|
|
7079
|
+
descriptorDigest
|
|
7080
|
+
}) {
|
|
7081
|
+
return hashJson({
|
|
7082
|
+
digestVersion: "interaction-draft@2",
|
|
7083
|
+
actorSeat,
|
|
7084
|
+
descriptorDigest,
|
|
7085
|
+
emitted: false,
|
|
7086
|
+
interactionId: descriptor.interactionId,
|
|
7087
|
+
interactionKey: descriptor.interactionKey,
|
|
7088
|
+
values: defaultsForDescriptor(descriptor)
|
|
7089
|
+
});
|
|
7090
|
+
}
|
|
7091
|
+
function toDescriptorDigestJson(value) {
|
|
7092
|
+
const canonical = toCanonicalJson(value);
|
|
7093
|
+
return normalizeOrderInsensitiveDescriptorFields(canonical);
|
|
7094
|
+
}
|
|
7095
|
+
function normalizeOrderInsensitiveDescriptorFields(value) {
|
|
7096
|
+
if (Array.isArray(value)) {
|
|
7097
|
+
return value.map(normalizeOrderInsensitiveDescriptorFields);
|
|
7098
|
+
}
|
|
7099
|
+
if (value === null || typeof value !== "object") {
|
|
7100
|
+
return value;
|
|
7101
|
+
}
|
|
7102
|
+
return Object.fromEntries(
|
|
7103
|
+
Object.entries(value).map(([key, item]) => {
|
|
7104
|
+
const normalized = normalizeOrderInsensitiveDescriptorFields(item);
|
|
7105
|
+
if ((key === "eligibleTargets" || key === "dependentCases") && Array.isArray(normalized)) {
|
|
7106
|
+
return [
|
|
7107
|
+
key,
|
|
7108
|
+
[...normalized].sort(
|
|
7109
|
+
(left, right) => compareCanonicalJson(canonicalJson(left), canonicalJson(right))
|
|
7110
|
+
)
|
|
7111
|
+
];
|
|
7112
|
+
}
|
|
7113
|
+
return [key, normalized];
|
|
7114
|
+
})
|
|
7115
|
+
);
|
|
7116
|
+
}
|
|
7117
|
+
function defaultsForDescriptor(descriptor) {
|
|
7118
|
+
return Object.fromEntries(
|
|
7119
|
+
descriptor.inputs.flatMap(
|
|
7120
|
+
(input) => input.defaultValue === void 0 ? [] : [[input.key, toCanonicalJson(input.defaultValue)]]
|
|
7121
|
+
)
|
|
7122
|
+
);
|
|
7123
|
+
}
|
|
7124
|
+
function toCanonicalJson(value) {
|
|
7125
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") {
|
|
7126
|
+
return value;
|
|
7127
|
+
}
|
|
7128
|
+
if (typeof value === "number") {
|
|
7129
|
+
return value;
|
|
7130
|
+
}
|
|
7131
|
+
if (Array.isArray(value)) {
|
|
7132
|
+
return value.map((item) => toCanonicalJson(item));
|
|
7133
|
+
}
|
|
7134
|
+
if (typeof value === "object") {
|
|
7135
|
+
return Object.fromEntries(
|
|
7136
|
+
Object.entries(value).filter(([, item]) => item !== void 0).map(([key, item]) => [key, toCanonicalJson(item)])
|
|
7137
|
+
);
|
|
7138
|
+
}
|
|
7139
|
+
return null;
|
|
7140
|
+
}
|
|
7141
|
+
function hashJson(value) {
|
|
7142
|
+
return `sha256:${sha256Hex(canonicalJson(value))}`;
|
|
7143
|
+
}
|
|
7144
|
+
function canonicalJson(value) {
|
|
7145
|
+
return JSON.stringify(canonicalizeJson(value));
|
|
7146
|
+
}
|
|
7147
|
+
function canonicalizeJson(value) {
|
|
7148
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") {
|
|
7149
|
+
return value;
|
|
7150
|
+
}
|
|
7151
|
+
if (typeof value === "number") {
|
|
7152
|
+
if (!Number.isFinite(value)) {
|
|
7153
|
+
throw new Error("canonical JSON contains a non-finite number");
|
|
7154
|
+
}
|
|
7155
|
+
return value;
|
|
7156
|
+
}
|
|
7157
|
+
if (Array.isArray(value)) {
|
|
7158
|
+
return value.map((item) => canonicalizeJson(item));
|
|
7159
|
+
}
|
|
7160
|
+
return Object.fromEntries(
|
|
7161
|
+
Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, item]) => [key, canonicalizeJson(item)])
|
|
7162
|
+
);
|
|
7163
|
+
}
|
|
7164
|
+
function compareCanonicalJson(left, right) {
|
|
7165
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
7166
|
+
}
|
|
7039
7167
|
function stableStringify(value) {
|
|
7040
7168
|
if (value === null || typeof value !== "object") {
|
|
7041
7169
|
return JSON.stringify(value);
|
|
@@ -7055,6 +7183,171 @@ function fnv1a64(value) {
|
|
|
7055
7183
|
}
|
|
7056
7184
|
return hash.toString(16).padStart(16, "0");
|
|
7057
7185
|
}
|
|
7186
|
+
var SHA256_K = [
|
|
7187
|
+
1116352408,
|
|
7188
|
+
1899447441,
|
|
7189
|
+
3049323471,
|
|
7190
|
+
3921009573,
|
|
7191
|
+
961987163,
|
|
7192
|
+
1508970993,
|
|
7193
|
+
2453635748,
|
|
7194
|
+
2870763221,
|
|
7195
|
+
3624381080,
|
|
7196
|
+
310598401,
|
|
7197
|
+
607225278,
|
|
7198
|
+
1426881987,
|
|
7199
|
+
1925078388,
|
|
7200
|
+
2162078206,
|
|
7201
|
+
2614888103,
|
|
7202
|
+
3248222580,
|
|
7203
|
+
3835390401,
|
|
7204
|
+
4022224774,
|
|
7205
|
+
264347078,
|
|
7206
|
+
604807628,
|
|
7207
|
+
770255983,
|
|
7208
|
+
1249150122,
|
|
7209
|
+
1555081692,
|
|
7210
|
+
1996064986,
|
|
7211
|
+
2554220882,
|
|
7212
|
+
2821834349,
|
|
7213
|
+
2952996808,
|
|
7214
|
+
3210313671,
|
|
7215
|
+
3336571891,
|
|
7216
|
+
3584528711,
|
|
7217
|
+
113926993,
|
|
7218
|
+
338241895,
|
|
7219
|
+
666307205,
|
|
7220
|
+
773529912,
|
|
7221
|
+
1294757372,
|
|
7222
|
+
1396182291,
|
|
7223
|
+
1695183700,
|
|
7224
|
+
1986661051,
|
|
7225
|
+
2177026350,
|
|
7226
|
+
2456956037,
|
|
7227
|
+
2730485921,
|
|
7228
|
+
2820302411,
|
|
7229
|
+
3259730800,
|
|
7230
|
+
3345764771,
|
|
7231
|
+
3516065817,
|
|
7232
|
+
3600352804,
|
|
7233
|
+
4094571909,
|
|
7234
|
+
275423344,
|
|
7235
|
+
430227734,
|
|
7236
|
+
506948616,
|
|
7237
|
+
659060556,
|
|
7238
|
+
883997877,
|
|
7239
|
+
958139571,
|
|
7240
|
+
1322822218,
|
|
7241
|
+
1537002063,
|
|
7242
|
+
1747873779,
|
|
7243
|
+
1955562222,
|
|
7244
|
+
2024104815,
|
|
7245
|
+
2227730452,
|
|
7246
|
+
2361852424,
|
|
7247
|
+
2428436474,
|
|
7248
|
+
2756734187,
|
|
7249
|
+
3204031479,
|
|
7250
|
+
3329325298
|
|
7251
|
+
];
|
|
7252
|
+
function sha256Hex(input) {
|
|
7253
|
+
const bytes = utf8Bytes(input);
|
|
7254
|
+
const bitLength = bytes.length * 8;
|
|
7255
|
+
bytes.push(128);
|
|
7256
|
+
while (bytes.length % 64 !== 56) {
|
|
7257
|
+
bytes.push(0);
|
|
7258
|
+
}
|
|
7259
|
+
for (let shift = 56; shift >= 0; shift -= 8) {
|
|
7260
|
+
bytes.push(Math.floor(bitLength / 2 ** shift) & 255);
|
|
7261
|
+
}
|
|
7262
|
+
let h0 = 1779033703;
|
|
7263
|
+
let h1 = 3144134277;
|
|
7264
|
+
let h2 = 1013904242;
|
|
7265
|
+
let h3 = 2773480762;
|
|
7266
|
+
let h4 = 1359893119;
|
|
7267
|
+
let h5 = 2600822924;
|
|
7268
|
+
let h6 = 528734635;
|
|
7269
|
+
let h7 = 1541459225;
|
|
7270
|
+
const words = new Array(64);
|
|
7271
|
+
for (let offset = 0; offset < bytes.length; offset += 64) {
|
|
7272
|
+
for (let index = 0; index < 16; index += 1) {
|
|
7273
|
+
const base = offset + index * 4;
|
|
7274
|
+
words[index] = (bytes[base] << 24 | bytes[base + 1] << 16 | bytes[base + 2] << 8 | bytes[base + 3]) >>> 0;
|
|
7275
|
+
}
|
|
7276
|
+
for (let index = 16; index < 64; index += 1) {
|
|
7277
|
+
const s0 = rotateRight(words[index - 15], 7) ^ rotateRight(words[index - 15], 18) ^ words[index - 15] >>> 3;
|
|
7278
|
+
const s1 = rotateRight(words[index - 2], 17) ^ rotateRight(words[index - 2], 19) ^ words[index - 2] >>> 10;
|
|
7279
|
+
words[index] = words[index - 16] + s0 + words[index - 7] + s1 >>> 0;
|
|
7280
|
+
}
|
|
7281
|
+
let a = h0;
|
|
7282
|
+
let b = h1;
|
|
7283
|
+
let c = h2;
|
|
7284
|
+
let d = h3;
|
|
7285
|
+
let e = h4;
|
|
7286
|
+
let f = h5;
|
|
7287
|
+
let g = h6;
|
|
7288
|
+
let h = h7;
|
|
7289
|
+
for (let index = 0; index < 64; index += 1) {
|
|
7290
|
+
const s1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);
|
|
7291
|
+
const ch = e & f ^ ~e & g;
|
|
7292
|
+
const temp1 = h + s1 + ch + SHA256_K[index] + words[index] >>> 0;
|
|
7293
|
+
const s0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
|
|
7294
|
+
const maj = a & b ^ a & c ^ b & c;
|
|
7295
|
+
const temp2 = s0 + maj >>> 0;
|
|
7296
|
+
h = g;
|
|
7297
|
+
g = f;
|
|
7298
|
+
f = e;
|
|
7299
|
+
e = d + temp1 >>> 0;
|
|
7300
|
+
d = c;
|
|
7301
|
+
c = b;
|
|
7302
|
+
b = a;
|
|
7303
|
+
a = temp1 + temp2 >>> 0;
|
|
7304
|
+
}
|
|
7305
|
+
h0 = h0 + a >>> 0;
|
|
7306
|
+
h1 = h1 + b >>> 0;
|
|
7307
|
+
h2 = h2 + c >>> 0;
|
|
7308
|
+
h3 = h3 + d >>> 0;
|
|
7309
|
+
h4 = h4 + e >>> 0;
|
|
7310
|
+
h5 = h5 + f >>> 0;
|
|
7311
|
+
h6 = h6 + g >>> 0;
|
|
7312
|
+
h7 = h7 + h >>> 0;
|
|
7313
|
+
}
|
|
7314
|
+
return [h0, h1, h2, h3, h4, h5, h6, h7].map((word) => word.toString(16).padStart(8, "0")).join("");
|
|
7315
|
+
}
|
|
7316
|
+
function rotateRight(value, shift) {
|
|
7317
|
+
return value >>> shift | value << 32 - shift;
|
|
7318
|
+
}
|
|
7319
|
+
function utf8Bytes(input) {
|
|
7320
|
+
const bytes = [];
|
|
7321
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
7322
|
+
let codePoint = input.charCodeAt(index);
|
|
7323
|
+
if (codePoint >= 55296 && codePoint <= 56319 && index + 1 < input.length) {
|
|
7324
|
+
const low = input.charCodeAt(index + 1);
|
|
7325
|
+
if (low >= 56320 && low <= 57343) {
|
|
7326
|
+
codePoint = 65536 + (codePoint - 55296 << 10) + (low - 56320);
|
|
7327
|
+
index += 1;
|
|
7328
|
+
}
|
|
7329
|
+
}
|
|
7330
|
+
if (codePoint < 128) {
|
|
7331
|
+
bytes.push(codePoint);
|
|
7332
|
+
} else if (codePoint < 2048) {
|
|
7333
|
+
bytes.push(192 | codePoint >>> 6, 128 | codePoint & 63);
|
|
7334
|
+
} else if (codePoint < 65536) {
|
|
7335
|
+
bytes.push(
|
|
7336
|
+
224 | codePoint >>> 12,
|
|
7337
|
+
128 | codePoint >>> 6 & 63,
|
|
7338
|
+
128 | codePoint & 63
|
|
7339
|
+
);
|
|
7340
|
+
} else {
|
|
7341
|
+
bytes.push(
|
|
7342
|
+
240 | codePoint >>> 18,
|
|
7343
|
+
128 | codePoint >>> 12 & 63,
|
|
7344
|
+
128 | codePoint >>> 6 & 63,
|
|
7345
|
+
128 | codePoint & 63
|
|
7346
|
+
);
|
|
7347
|
+
}
|
|
7348
|
+
}
|
|
7349
|
+
return bytes;
|
|
7350
|
+
}
|
|
7058
7351
|
|
|
7059
7352
|
// src/reducer/bundle/trusted/static-projection.ts
|
|
7060
7353
|
function stableStringify2(value) {
|