@bake-native/core 0.0.0 → 0.1.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/THIRD_PARTY_NOTICES.txt +548 -0
- package/bake-prelude.js +189 -0
- package/batch-contract.json +21 -0
- package/batch-wire.js +674 -0
- package/compat.json +64 -0
- package/controls.css +108 -0
- package/determinism.js +175 -0
- package/devtools.d.ts +13 -0
- package/devtools.js +73 -0
- package/dialogs.js +59 -0
- package/direct-style.js +105 -0
- package/direct-table.js +261 -0
- package/dist/bake.mjs +2211 -0
- package/dist/build-CMsvCcZ0.mjs +1 -0
- package/dist/build-CkLSZw06.mjs +5514 -0
- package/dist/build-tools-Dxyl6XAf.mjs +80 -0
- package/dist/client-Cm7o6dQd.mjs +17544 -0
- package/dist/compiler.mjs +4 -0
- package/dist/config-B1W8gfZY.mjs +12 -0
- package/dist/dev-Cskd8Hl4.mjs +986 -0
- package/dist/direct-report-Bdda-k_Y.mjs +153 -0
- package/dist/direct-report-Du44nNWl.mjs +1 -0
- package/dist/index.d.mts +176 -0
- package/dist/index.mjs +1 -0
- package/dist/intl-ROnAp2qO.mjs +75 -0
- package/dist/jiti-stub-CKcaShwE.mjs +5 -0
- package/dist/native-views-BuzB9x5H.mjs +7849 -0
- package/dist/octane/package.json +5 -0
- package/dist/package-KkUSMoji.mjs +2784 -0
- package/dist/react/package.json +13 -0
- package/dist/rolldown-runtime-D3KUYPsf.mjs +12 -0
- package/dist/run-D2aPm54a.mjs +6632 -0
- package/dist/scope-8W2aIuQ9.mjs +262 -0
- package/dist/screens/BakeNativeScreen.native.ts +9 -0
- package/dist/screens/package.json +5 -0
- package/dom-exception.js +31 -0
- package/element-api.js +158 -0
- package/first-screen.js +30 -0
- package/fonts/Geist-Italic-Variable.ttf +0 -0
- package/fonts/Geist-Variable.ttf +0 -0
- package/fonts/GeistMono-Italic-Variable.ttf +0 -0
- package/fonts/GeistMono-Variable.ttf +0 -0
- package/fonts/OFL.txt +93 -0
- package/fonts/README.md +27 -0
- package/fonts/geist-italic.css +8 -0
- package/fonts/geist-mono-italic.css +8 -0
- package/fonts/geist-mono.css +8 -0
- package/fonts/geist.css +8 -0
- package/header-icons.json +53 -0
- package/host-runtime.js +508 -0
- package/image-props.js +17 -0
- package/index.d.ts +8 -0
- package/index.js +7 -0
- package/licenses/Apache-2.0.txt +73 -0
- package/locale-entry.d.ts +1 -0
- package/locale-entry.js +1 -0
- package/locale.d.ts +28 -0
- package/locale.js +124 -0
- package/markup-support.js +87 -0
- package/media-element.js +115 -0
- package/native-args-entry.js +2 -0
- package/native-args.d.ts +7 -0
- package/native-args.js +155 -0
- package/native-entry.js +1 -0
- package/native-globals.d.ts +156 -0
- package/native-scenarios.d.ts +17 -0
- package/native-scenarios.js +46 -0
- package/native-support.json +349 -0
- package/native.d.ts +52 -0
- package/native.js +237 -0
- package/package.json +142 -4
- package/page-elements.js +123 -0
- package/runtime-provides.json +412 -0
- package/safe-area.d.ts +1 -0
- package/safe-area.js +44 -0
- package/swift-ui/modifiers.js +164 -0
- package/tab-icons.js +62 -0
- package/templates/create/tabs/AGENTS.md +22 -0
- package/templates/create/tabs/README.md +43 -0
- package/templates/create/tabs/_gitignore +13 -0
- package/templates/create/tabs/android/app/build.gradle.kts +79 -0
- package/templates/create/tabs/android/app/src/main/AndroidManifest.xml +39 -0
- package/templates/create/tabs/android/app/src/main/kotlin/MainActivity.kt +35 -0
- package/templates/create/tabs/android/app/src/main/res/values/themes.xml +8 -0
- package/templates/create/tabs/android/build.gradle.kts +5 -0
- package/templates/create/tabs/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/templates/create/tabs/android/gradle/wrapper/gradle-wrapper.properties +9 -0
- package/templates/create/tabs/android/gradle.properties +3 -0
- package/templates/create/tabs/android/gradlew +248 -0
- package/templates/create/tabs/android/settings.gradle.kts +47 -0
- package/templates/create/tabs/bake.config.ts +10 -0
- package/templates/create/tabs/ios/App/App.swift +30 -0
- package/templates/create/tabs/ios/build.sh +23 -0
- package/templates/create/tabs/ios/project.yml +57 -0
- package/templates/create/tabs/macos/Package.swift +24 -0
- package/templates/create/tabs/macos/Sources/__SWIFT_NAME__/App.swift +146 -0
- package/templates/create/tabs/macos/build.sh +4 -0
- package/templates/create/tabs/package.json +23 -0
- package/templates/create/tabs/pnpm-workspace.yaml +6 -0
- package/templates/create/tabs/src/App.tsrx +92 -0
- package/templates/create/tabs/src/App.tsx +67 -0
- package/templates/create/tabs/src/styles.css +32 -0
- package/templates/create/tabs/tsconfig.json +5 -0
- package/templates/create/tabs/windows/Cargo.toml +29 -0
- package/templates/create/tabs/windows/build.rs +9 -0
- package/templates/create/tabs/windows/src/main.rs +52 -0
- package/templates/create/tabs/windows/src/shell.rs +316 -0
- package/templates/module/__NAME__.kt +20 -0
- package/templates/module/__NAME__.native.ts +24 -0
- package/templates/module/__NAME__.swift +25 -0
- package/templates/module/__NAME__.web.ts +13 -0
- package/templates/module/__NAME__Test.kt +26 -0
- package/templates/module/__NAME__Tests.swift +25 -0
- package/templates/module/__SNAKE__.rs +43 -0
- package/text.d.ts +20 -0
- package/text.js +100 -0
- package/transform-entry.js +1 -0
- package/transform.d.ts +15 -0
- package/transform.js +98 -0
- package/tsconfig.native.json +16 -0
- package/ui/scope.js +103 -0
- package/ui/swift.js +106 -0
- package/ui/ui.css +272 -0
- package/view-ref-writer.js +268 -0
- package/view-ref.d.ts +26 -0
- package/view-ref.js +85 -0
- package/views/Video.native.ts +68 -0
- package/views/generated/VideoViewAndroid.h +68 -0
- package/views/generated/VideoViewJSI.h +94 -0
- package/views/generated/VideoViewSpec.kt +113 -0
- package/views/generated/apple/VideoViewJSI/VideoViewJSIApple.cpp +40 -0
- package/views/generated/apple/VideoViewJSI/include/VideoViewJSIApple.h +28 -0
- package/views/generated/apple/VideoViewSpec/VideoViewInterop.swift +39 -0
- package/views/generated/apple/VideoViewSpec/VideoViewSpec.swift +186 -0
- package/views/generated/video_view_spec.rs +189 -0
- package/views.d.ts +24 -0
- package/views.js +45 -0
- package/virtual-window.js +35 -0
- package/visibility.js +75 -0
- package/web-crypto.js +84 -0
- package/web-fetch.js +1071 -0
- package/README.md +0 -3
package/batch-wire.js
ADDED
|
@@ -0,0 +1,674 @@
|
|
|
1
|
+
// Generated by bake-abi-gen from native/rust/schema/batch.oschema. Do not edit.
|
|
2
|
+
// Renderer batch stream writer: one ArrayBuffer per Octane commit, read by the
|
|
3
|
+
// generated Rust reader (schema/generated/rust/batch_wire.rs). BATCH_DIGEST must match the
|
|
4
|
+
// runtime's; the bundle's manifest.json records it as `batchDigest`.
|
|
5
|
+
|
|
6
|
+
export const BATCH_DIGEST = '0xd4c77b3d54621b67';
|
|
7
|
+
const DIGEST_LO = 0x54621b67;
|
|
8
|
+
const DIGEST_HI = 0xd4c77b3d;
|
|
9
|
+
const MAGIC = 0x3242434f; // "OCB2"
|
|
10
|
+
const SEED = ["native", "click", "discrete", "default", "continuous", "hidden", "visible", "value", "class", "className", "style", "id", "type", "role", "title", "label", "disabled", "checked", "placeholder", "data-expect", "aria-label", "aria-hidden", "aria-pressed", "modifiers", "$type", "#text", "div", "span", "p", "main", "button", "section", "header", "footer", "img", "input", "svg", "path", "left", "top", "right", "bottom", "width", "height", "position", "backgroundColor", "color", "opacity", "transform", "fill", "stroke", "d"];
|
|
11
|
+
const TABLES = 1;
|
|
12
|
+
const internsValue = (k) => k === "class" || k === "className";
|
|
13
|
+
|
|
14
|
+
// Persistent tables: strings up to STRING_CAP entries (each at most STRING_MAX UTF-16 units), each
|
|
15
|
+
// intern table up to TABLE_CAP entries; beyond that values are sent inline.
|
|
16
|
+
const STRING_CAP = 8192;
|
|
17
|
+
const STRING_MAX = 256;
|
|
18
|
+
const TABLE_CAP = 4096;
|
|
19
|
+
const MAX_UINT = 0x3ffffffffffff; // 2^50 - 1: uv(n * 8 + kind) stays a safe integer
|
|
20
|
+
|
|
21
|
+
function isUint(x) {
|
|
22
|
+
return typeof x === 'number' && x >= 0 && x <= MAX_UINT && Math.floor(x) === x;
|
|
23
|
+
}
|
|
24
|
+
function isInt(x) {
|
|
25
|
+
return typeof x === 'number' && x >= -MAX_UINT && x <= MAX_UINT && Math.floor(x) === x;
|
|
26
|
+
}
|
|
27
|
+
function omitted(x) {
|
|
28
|
+
return x === undefined || typeof x === 'function' || typeof x === 'symbol';
|
|
29
|
+
}
|
|
30
|
+
function isProps(x) {
|
|
31
|
+
return x !== null && typeof x === 'object' && !Array.isArray(x) && typeof x.toJSON !== 'function';
|
|
32
|
+
}
|
|
33
|
+
// A `transform` field: CSS text, or a numeric transform (@bake-native/octane).
|
|
34
|
+
function isTransform(x) {
|
|
35
|
+
return typeof x === 'string' || (x !== null && typeof x === 'object' && Array.isArray(x.$$bakeTransform));
|
|
36
|
+
}
|
|
37
|
+
// A number String() prints without an exponent (what the reader prints back as the same text).
|
|
38
|
+
function printable(x) {
|
|
39
|
+
return typeof x === 'number' && (x === 0 || (x > 0 ? x >= 1e-6 && x < 1e21 : x <= -1e-6 && x > -1e21));
|
|
40
|
+
}
|
|
41
|
+
function listOf(x, check) {
|
|
42
|
+
if (!Array.isArray(x)) return false;
|
|
43
|
+
for (let i = 0; i < x.length; i++) if (!check(x[i])) return false;
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
// The object's own enumerable keys are exactly `names`, in that order.
|
|
47
|
+
function keys(x, names) {
|
|
48
|
+
let i = 0;
|
|
49
|
+
for (const k in x) if (k !== names[i++]) return false;
|
|
50
|
+
return i === names.length;
|
|
51
|
+
}
|
|
52
|
+
function keysWithOptional(x, names, optional) {
|
|
53
|
+
let i = 0;
|
|
54
|
+
for (const k in x) {
|
|
55
|
+
while (i < names.length && names[i] !== k && optional[i]) i++;
|
|
56
|
+
if (names[i] !== k) return false;
|
|
57
|
+
i++;
|
|
58
|
+
}
|
|
59
|
+
while (i < names.length && optional[i]) i++;
|
|
60
|
+
return i === names.length;
|
|
61
|
+
}
|
|
62
|
+
// As JSON.stringify: only objects consult toJSON; boxed primitives unwrap.
|
|
63
|
+
function normalize(value, key) {
|
|
64
|
+
if (value === null || typeof value !== 'object') return value;
|
|
65
|
+
if (typeof value.toJSON === 'function') value = value.toJSON(typeof key === 'number' ? String(key) : key);
|
|
66
|
+
if (value instanceof Number || value instanceof String || value instanceof Boolean) return value.valueOf();
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// The VM's own TextEncoder (Hermes, browsers, Node), read when this module loads: before
|
|
71
|
+
// the fetch implementation can install its JS polyfill, which would be no faster than the loop.
|
|
72
|
+
const nativeUtf8 = typeof TextEncoder === 'function' && typeof TextEncoder.prototype.encodeInto === 'function' ? new TextEncoder() : null;
|
|
73
|
+
const NATIVE_UTF8_MIN = 16;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A writer for one VM: its tables persist across batches (the reader keeps the same ones).
|
|
77
|
+
* `replacers`: by op name, for an op that `replaces` another (batch.oschema), a function given
|
|
78
|
+
* each command of the replaced op that returns the record to send instead, or undefined.
|
|
79
|
+
*/
|
|
80
|
+
export function createBatchWriter(replacers = {}) {
|
|
81
|
+
let bytes = new Uint8Array(16384);
|
|
82
|
+
// bytes.length, kept here: Hermes reads a typed array's length through a native getter.
|
|
83
|
+
let cap = bytes.length;
|
|
84
|
+
let view = new DataView(bytes.buffer);
|
|
85
|
+
let o = 0;
|
|
86
|
+
const strings = new Map();
|
|
87
|
+
for (let i = 0; i < SEED.length; i++) strings.set(SEED[i], i);
|
|
88
|
+
let stringCount = SEED.length;
|
|
89
|
+
const tableMaps = [];
|
|
90
|
+
const tableCounts = [];
|
|
91
|
+
for (let t = 0; t < TABLES; t++) { tableMaps.push(new WeakMap()); tableCounts.push(0); }
|
|
92
|
+
// Definitions made by the last encode, undone by rollback() when its batch is not sent.
|
|
93
|
+
let defined = [];
|
|
94
|
+
let tableDefined = tableCounts.map(() => []);
|
|
95
|
+
const checked = new WeakMap();
|
|
96
|
+
const masks = new WeakMap();
|
|
97
|
+
const local = new Map();
|
|
98
|
+
let localCount = 0;
|
|
99
|
+
|
|
100
|
+
function grow(n) {
|
|
101
|
+
const next = new Uint8Array(Math.max(o + n, cap * 2));
|
|
102
|
+
next.set(bytes.subarray(0, o));
|
|
103
|
+
bytes = next;
|
|
104
|
+
cap = next.length;
|
|
105
|
+
view = new DataView(bytes.buffer);
|
|
106
|
+
}
|
|
107
|
+
function uv(n) {
|
|
108
|
+
if (o + 10 > cap) grow(10);
|
|
109
|
+
if (n < 0x10000000) {
|
|
110
|
+
while (n >= 128) { bytes[o++] = (n & 127) | 128; n >>>= 7; }
|
|
111
|
+
bytes[o++] = n;
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
while (n >= 128) { bytes[o++] = (n % 128) | 128; n = Math.floor(n / 128); }
|
|
115
|
+
bytes[o++] = n;
|
|
116
|
+
}
|
|
117
|
+
// UTF-8 with lone surrogates as U+FFFD, behind a head uv(byteLength * 8 + kind). The head is
|
|
118
|
+
// sized for one byte per UTF-16 unit and moved when the text is not ASCII.
|
|
119
|
+
function text(s, kind) {
|
|
120
|
+
const length = s.length;
|
|
121
|
+
const guess = length * 8 + kind;
|
|
122
|
+
const hsize = guess < 0x80 ? 1 : guess < 0x4000 ? 2 : guess < 0x200000 ? 3 : guess < 0x10000000 ? 4 : 5;
|
|
123
|
+
if (o + hsize + 1 + length * 3 > cap) grow(hsize + 1 + length * 3);
|
|
124
|
+
const start = o + hsize;
|
|
125
|
+
let p = start;
|
|
126
|
+
// Long strings (inline transforms, text): the VM's native TextEncoder writes the same bytes
|
|
127
|
+
// (lone surrogates as U+FFFD) without a bytecode loop per character.
|
|
128
|
+
if (length >= NATIVE_UTF8_MIN && nativeUtf8 !== null) p += nativeUtf8.encodeInto(s, bytes.subarray(start, start + length * 3)).written;
|
|
129
|
+
else for (let i = 0; i < length; i++) {
|
|
130
|
+
let cp = s.charCodeAt(i);
|
|
131
|
+
if (cp < 0x80) { bytes[p++] = cp; continue; }
|
|
132
|
+
if (cp >= 0xd800 && cp <= 0xdfff) {
|
|
133
|
+
const low = cp <= 0xdbff && i + 1 < length ? s.charCodeAt(i + 1) : 0;
|
|
134
|
+
if (low >= 0xdc00 && low <= 0xdfff) { cp = 0x10000 + ((cp - 0xd800) << 10) + (low - 0xdc00); i++; }
|
|
135
|
+
else cp = 0xfffd;
|
|
136
|
+
}
|
|
137
|
+
if (cp >= 0x10000) {
|
|
138
|
+
bytes[p++] = 0xf0 | (cp >> 18);
|
|
139
|
+
bytes[p++] = 0x80 | ((cp >> 12) & 63);
|
|
140
|
+
bytes[p++] = 0x80 | ((cp >> 6) & 63);
|
|
141
|
+
} else if (cp >= 0x800) {
|
|
142
|
+
bytes[p++] = 0xe0 | (cp >> 12);
|
|
143
|
+
bytes[p++] = 0x80 | ((cp >> 6) & 63);
|
|
144
|
+
} else bytes[p++] = 0xc0 | (cp >> 6);
|
|
145
|
+
bytes[p++] = 0x80 | (cp & 63);
|
|
146
|
+
}
|
|
147
|
+
let head = guess;
|
|
148
|
+
if (p - start !== length) {
|
|
149
|
+
head = (p - start) * 8 + kind;
|
|
150
|
+
const need = head < 0x80 ? 1 : head < 0x4000 ? 2 : head < 0x200000 ? 3 : head < 0x10000000 ? 4 : 5;
|
|
151
|
+
if (need !== hsize) { bytes.copyWithin(o + need, start, p); p += need - hsize; }
|
|
152
|
+
}
|
|
153
|
+
while (head >= 128) { bytes[o++] = (head % 128) | 128; head = Math.floor(head / 128); }
|
|
154
|
+
bytes[o++] = head;
|
|
155
|
+
o = p;
|
|
156
|
+
}
|
|
157
|
+
// A string interned for the VM's lifetime (kinds 3 define, 4 reference).
|
|
158
|
+
function sym(s) {
|
|
159
|
+
const i = strings.get(s);
|
|
160
|
+
if (i !== undefined) { uv(i * 8 + 4); return; }
|
|
161
|
+
if (stringCount < STRING_CAP && s.length <= STRING_MAX) {
|
|
162
|
+
strings.set(s, stringCount++);
|
|
163
|
+
defined.push(s);
|
|
164
|
+
text(s, 3);
|
|
165
|
+
} else text(s, 2);
|
|
166
|
+
}
|
|
167
|
+
// A string deduplicated within the batch (kinds 5 define, 6 reference); short ones inline.
|
|
168
|
+
function str(s) {
|
|
169
|
+
if (s.length < 4) { text(s, 2); return; }
|
|
170
|
+
const i = local.get(s);
|
|
171
|
+
if (i !== undefined) { uv(i * 8 + 6); return; }
|
|
172
|
+
local.set(s, localCount++);
|
|
173
|
+
text(s, 5);
|
|
174
|
+
}
|
|
175
|
+
function num(v) {
|
|
176
|
+
if (v >= 0) {
|
|
177
|
+
if (v <= MAX_UINT && Math.floor(v) === v) { uv(v * 8 + 1); return; }
|
|
178
|
+
} else if (v >= -MAX_UINT && Math.floor(v) === v) { uv(48); uv(-v); return; }
|
|
179
|
+
if (v !== v || v === Infinity || v === -Infinity) { uv(0); return; }
|
|
180
|
+
if (o + 9 > cap) grow(9);
|
|
181
|
+
bytes[o++] = 24;
|
|
182
|
+
view.setFloat64(o, v, true);
|
|
183
|
+
o += 8;
|
|
184
|
+
}
|
|
185
|
+
// A CSS transform: its text (uv 0, then str), or n >= 1 functions of a numeric transform
|
|
186
|
+
// (@bake-native/octane: `$$bakeTransform` = [kind, x, y, ...]): uv n, then per function a kind
|
|
187
|
+
// byte (1 translate px, 2 scale, 3 rotate deg) and x, y as f64le. The reader prints them as
|
|
188
|
+
// String(t) does; a numeric transform it could not (no functions, an unknown kind, a number
|
|
189
|
+
// String() prints with an exponent, NaN) goes as its text.
|
|
190
|
+
function transform(t) {
|
|
191
|
+
if (typeof t === 'string') { uv(0); str(t); return; }
|
|
192
|
+
const f = t.$$bakeTransform;
|
|
193
|
+
const n = f.length;
|
|
194
|
+
let ok = n > 0 && n % 3 === 0;
|
|
195
|
+
for (let i = 0; ok && i < n; i += 3) {
|
|
196
|
+
const k = f[i];
|
|
197
|
+
ok = (k === 1 || k === 2 || k === 3) && printable(f[i + 1]) && printable(f[i + 2]);
|
|
198
|
+
}
|
|
199
|
+
if (!ok) { uv(0); str(String(t)); return; }
|
|
200
|
+
const count = n / 3;
|
|
201
|
+
uv(count);
|
|
202
|
+
if (o + count * 17 > cap) grow(count * 17);
|
|
203
|
+
for (let i = 0; i < n; i += 3) {
|
|
204
|
+
bytes[o++] = f[i];
|
|
205
|
+
// + 0: -0 prints as 0.
|
|
206
|
+
view.setFloat64(o, f[i + 1] + 0, true);
|
|
207
|
+
view.setFloat64(o + 8, f[i + 2] + 0, true);
|
|
208
|
+
o += 16;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// A count written after its items: one byte reserved, moved when it needs more.
|
|
212
|
+
function count(at, n) {
|
|
213
|
+
if (n < 128) { bytes[at] = n; return; }
|
|
214
|
+
const need = n < 0x4000 ? 2 : n < 0x200000 ? 3 : n < 0x10000000 ? 4 : 5;
|
|
215
|
+
if (o + need > cap) grow(need);
|
|
216
|
+
bytes.copyWithin(at + need, at + 1, o);
|
|
217
|
+
o += need - 1;
|
|
218
|
+
while (n >= 128) { bytes[at++] = (n & 127) | 128; n >>>= 7; }
|
|
219
|
+
bytes[at] = n;
|
|
220
|
+
}
|
|
221
|
+
function val(v, depth, intern) {
|
|
222
|
+
switch (typeof v) {
|
|
223
|
+
case 'string': if (intern) sym(v); else str(v); return;
|
|
224
|
+
case 'number': num(v); return;
|
|
225
|
+
case 'boolean': uv(v ? 16 : 8); return;
|
|
226
|
+
case 'object': break;
|
|
227
|
+
case 'bigint': throw new TypeError('Renderer batch value is a BigInt');
|
|
228
|
+
default: uv(0); return;
|
|
229
|
+
}
|
|
230
|
+
if (v === null) { uv(0); return; }
|
|
231
|
+
if (depth > 64) throw new TypeError('Renderer batch nested too deeply');
|
|
232
|
+
if (Array.isArray(v)) {
|
|
233
|
+
const n = v.length;
|
|
234
|
+
uv(32);
|
|
235
|
+
uv(n);
|
|
236
|
+
for (let i = 0; i < n; i++) {
|
|
237
|
+
const x = normalize(v[i], i);
|
|
238
|
+
if (omitted(x)) uv(0);
|
|
239
|
+
else val(x, depth + 1, false);
|
|
240
|
+
}
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
uv(40);
|
|
244
|
+
if (o + 1 > cap) grow(1);
|
|
245
|
+
const at = o++;
|
|
246
|
+
let n = 0;
|
|
247
|
+
for (const k of Object.keys(v)) {
|
|
248
|
+
// normalize() and omitted() inline for a primitive (most values): the same result.
|
|
249
|
+
let x = v[k];
|
|
250
|
+
if (x !== null && typeof x === 'object') { x = normalize(x, k); if (omitted(x)) continue; }
|
|
251
|
+
else if (x === undefined || typeof x === 'function' || typeof x === 'symbol') continue;
|
|
252
|
+
n++;
|
|
253
|
+
sym(k);
|
|
254
|
+
val(x, depth + 1, false);
|
|
255
|
+
}
|
|
256
|
+
count(at, n);
|
|
257
|
+
}
|
|
258
|
+
function props(p) {
|
|
259
|
+
if (o + 1 > cap) grow(1);
|
|
260
|
+
const at = o++;
|
|
261
|
+
let n = 0;
|
|
262
|
+
for (const k of Object.keys(p)) {
|
|
263
|
+
let x = p[k];
|
|
264
|
+
if (x !== null && typeof x === 'object') { x = normalize(x, k); if (omitted(x)) continue; }
|
|
265
|
+
else if (x === undefined || typeof x === 'function' || typeof x === 'symbol') continue;
|
|
266
|
+
n++;
|
|
267
|
+
sym(k);
|
|
268
|
+
val(x, 1, internsValue(k));
|
|
269
|
+
}
|
|
270
|
+
count(at, n);
|
|
271
|
+
}
|
|
272
|
+
function vals(v) {
|
|
273
|
+
const n = v.length;
|
|
274
|
+
uv(n);
|
|
275
|
+
for (let i = 0; i < n; i++) {
|
|
276
|
+
const x = normalize(v[i], i);
|
|
277
|
+
if (omitted(x)) uv(0);
|
|
278
|
+
else val(x, 1, false);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// A template program's slot policy: binding valueIndex -> intern its string values.
|
|
282
|
+
function slotMask(program) {
|
|
283
|
+
const mask = [];
|
|
284
|
+
for (const node of program.nodes) {
|
|
285
|
+
if (node.bindings === undefined) continue;
|
|
286
|
+
for (const b of node.bindings) mask[b.valueIndex] = internsValue(b.name);
|
|
287
|
+
}
|
|
288
|
+
for (let i = 0; i < mask.length; i++) mask[i] = mask[i] === true;
|
|
289
|
+
return mask;
|
|
290
|
+
}
|
|
291
|
+
function slots(v, program) {
|
|
292
|
+
const mask = masks.get(program) ?? [];
|
|
293
|
+
const width = mask.length;
|
|
294
|
+
const n = v.length;
|
|
295
|
+
uv(n);
|
|
296
|
+
for (let i = 0, j = 0; i < n; i++) {
|
|
297
|
+
const x = normalize(v[i], i);
|
|
298
|
+
if (omitted(x)) uv(0);
|
|
299
|
+
else val(x, 1, width > 0 && mask[j]);
|
|
300
|
+
if (++j === width) j = 0;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const K_Listener = ["id", "priority"];
|
|
304
|
+
function c_Listener(x) {
|
|
305
|
+
return x !== null && typeof x === 'object'
|
|
306
|
+
&& keys(x, K_Listener)
|
|
307
|
+
&& isUint(x.id)
|
|
308
|
+
&& typeof x.priority === 'string';
|
|
309
|
+
}
|
|
310
|
+
function w_Listener(x) {
|
|
311
|
+
uv(x.id);
|
|
312
|
+
sym(x.priority);
|
|
313
|
+
}
|
|
314
|
+
const K_Binding = ["name", "valueIndex"];
|
|
315
|
+
function c_Binding(x) {
|
|
316
|
+
return x !== null && typeof x === 'object'
|
|
317
|
+
&& keys(x, K_Binding)
|
|
318
|
+
&& typeof x.name === 'string'
|
|
319
|
+
&& isUint(x.valueIndex);
|
|
320
|
+
}
|
|
321
|
+
function w_Binding(x) {
|
|
322
|
+
sym(x.name);
|
|
323
|
+
uv(x.valueIndex);
|
|
324
|
+
}
|
|
325
|
+
const K_ProgramNode = ["type", "parent", "props", "bindings"];
|
|
326
|
+
const O_ProgramNode = [false, false, false, true];
|
|
327
|
+
function c_ProgramNode(x) {
|
|
328
|
+
return x !== null && typeof x === 'object'
|
|
329
|
+
&& keysWithOptional(x, K_ProgramNode, O_ProgramNode)
|
|
330
|
+
&& typeof x.type === 'string'
|
|
331
|
+
&& isInt(x.parent)
|
|
332
|
+
&& isProps(x.props)
|
|
333
|
+
&& (x.bindings === undefined || listOf(x.bindings, c_Binding));
|
|
334
|
+
}
|
|
335
|
+
function w_ProgramNode(x) {
|
|
336
|
+
sym(x.type);
|
|
337
|
+
uv(x.parent >= 0 ? x.parent * 2 : -x.parent * 2 - 1);
|
|
338
|
+
props(x.props);
|
|
339
|
+
if (x.bindings === undefined) uv(0); else { uv(1); { const l = x.bindings; const n = l.length; uv(n); for (let i = 0; i < n; i++) w_Binding(l[i]); } }
|
|
340
|
+
}
|
|
341
|
+
const K_ProgramEvent = ["node", "type", "priority"];
|
|
342
|
+
function c_ProgramEvent(x) {
|
|
343
|
+
return x !== null && typeof x === 'object'
|
|
344
|
+
&& keys(x, K_ProgramEvent)
|
|
345
|
+
&& isUint(x.node)
|
|
346
|
+
&& typeof x.type === 'string'
|
|
347
|
+
&& typeof x.priority === 'string';
|
|
348
|
+
}
|
|
349
|
+
function w_ProgramEvent(x) {
|
|
350
|
+
uv(x.node);
|
|
351
|
+
sym(x.type);
|
|
352
|
+
sym(x.priority);
|
|
353
|
+
}
|
|
354
|
+
// A template program (Octane `prepared.wire`): immutable, shared by every mount of a template.
|
|
355
|
+
const K_Program = ["nodes", "events"];
|
|
356
|
+
function c_Program(x) {
|
|
357
|
+
return x !== null && typeof x === 'object'
|
|
358
|
+
&& keys(x, K_Program)
|
|
359
|
+
&& listOf(x.nodes, c_ProgramNode)
|
|
360
|
+
&& listOf(x.events, c_ProgramEvent);
|
|
361
|
+
}
|
|
362
|
+
function i_Program(x) {
|
|
363
|
+
if (x === null || typeof x !== 'object') return false;
|
|
364
|
+
if (tableMaps[0].has(x)) return true;
|
|
365
|
+
let ok = checked.get(x);
|
|
366
|
+
if (ok === undefined) { ok = c_Program(x); checked.set(x, ok); if (ok) masks.set(x, slotMask(x)); }
|
|
367
|
+
return ok;
|
|
368
|
+
}
|
|
369
|
+
function intern_Program(x) {
|
|
370
|
+
const i = tableMaps[0].get(x);
|
|
371
|
+
if (i !== undefined) { uv(i + 2); return; }
|
|
372
|
+
if (tableCounts[0] < TABLE_CAP) {
|
|
373
|
+
tableMaps[0].set(x, tableCounts[0]++);
|
|
374
|
+
tableDefined[0].push(x);
|
|
375
|
+
uv(1);
|
|
376
|
+
} else uv(0);
|
|
377
|
+
w_Program(x);
|
|
378
|
+
}
|
|
379
|
+
function w_Program(x) {
|
|
380
|
+
{ const l = x.nodes; const n = l.length; uv(n); for (let i = 0; i < n; i++) w_ProgramNode(l[i]); }
|
|
381
|
+
{ const l = x.events; const n = l.length; uv(n); for (let i = 0; i < n; i++) w_ProgramEvent(l[i]); }
|
|
382
|
+
}
|
|
383
|
+
const K_ShapeNode = ["type", "parent"];
|
|
384
|
+
function c_ShapeNode(x) {
|
|
385
|
+
return x !== null && typeof x === 'object'
|
|
386
|
+
&& keys(x, K_ShapeNode)
|
|
387
|
+
&& typeof x.type === 'string'
|
|
388
|
+
&& isInt(x.parent);
|
|
389
|
+
}
|
|
390
|
+
function w_ShapeNode(x) {
|
|
391
|
+
sym(x.type);
|
|
392
|
+
uv(x.parent >= 0 ? x.parent * 2 : -x.parent * 2 - 1);
|
|
393
|
+
}
|
|
394
|
+
const K_NodeEvent = ["type", "listener"];
|
|
395
|
+
function c_NodeEvent(x) {
|
|
396
|
+
return x !== null && typeof x === 'object'
|
|
397
|
+
&& keys(x, K_NodeEvent)
|
|
398
|
+
&& typeof x.type === 'string'
|
|
399
|
+
&& (x.listener === null || c_Listener(x.listener));
|
|
400
|
+
}
|
|
401
|
+
function w_NodeEvent(x) {
|
|
402
|
+
sym(x.type);
|
|
403
|
+
if (x.listener === null) uv(0); else { uv(1); w_Listener(x.listener); }
|
|
404
|
+
}
|
|
405
|
+
const K_TemplateNode = ["id", "props", "events"];
|
|
406
|
+
const O_TemplateNode = [false, false, true];
|
|
407
|
+
function c_TemplateNode(x) {
|
|
408
|
+
return x !== null && typeof x === 'object'
|
|
409
|
+
&& keysWithOptional(x, K_TemplateNode, O_TemplateNode)
|
|
410
|
+
&& isUint(x.id)
|
|
411
|
+
&& isProps(x.props)
|
|
412
|
+
&& (x.events === undefined || listOf(x.events, c_NodeEvent));
|
|
413
|
+
}
|
|
414
|
+
function w_TemplateNode(x) {
|
|
415
|
+
uv(x.id);
|
|
416
|
+
props(x.props);
|
|
417
|
+
if (x.events === undefined) uv(0); else { uv(1); { const l = x.events; const n = l.length; uv(n); for (let i = 0; i < n; i++) w_NodeEvent(l[i]); } }
|
|
418
|
+
}
|
|
419
|
+
const replace_set_transform = replacers["set-transform"];
|
|
420
|
+
const K_op_create = ["op", "id", "type", "props"];
|
|
421
|
+
/** "create" = 1 */
|
|
422
|
+
function op_create(c) {
|
|
423
|
+
if (!(keys(c, K_op_create)
|
|
424
|
+
&& isUint(c.id)
|
|
425
|
+
&& typeof c.type === 'string'
|
|
426
|
+
&& isProps(c.props))) return false;
|
|
427
|
+
uv(1);
|
|
428
|
+
uv(c.id);
|
|
429
|
+
sym(c.type);
|
|
430
|
+
props(c.props);
|
|
431
|
+
return true;
|
|
432
|
+
}
|
|
433
|
+
const K_op_update = ["op", "id", "props"];
|
|
434
|
+
/** "update" = 2 */
|
|
435
|
+
function op_update(c) {
|
|
436
|
+
if (replace_set_transform !== undefined) { const r = replace_set_transform(c); if (r !== undefined && op_set_transform(r)) return true; }
|
|
437
|
+
if (!(keys(c, K_op_update)
|
|
438
|
+
&& isUint(c.id)
|
|
439
|
+
&& isProps(c.props))) return false;
|
|
440
|
+
uv(2);
|
|
441
|
+
uv(c.id);
|
|
442
|
+
props(c.props);
|
|
443
|
+
return true;
|
|
444
|
+
}
|
|
445
|
+
const K_op_recreate = ["op", "id", "type", "props"];
|
|
446
|
+
/** "recreate" = 3 */
|
|
447
|
+
function op_recreate(c) {
|
|
448
|
+
if (!(keys(c, K_op_recreate)
|
|
449
|
+
&& isUint(c.id)
|
|
450
|
+
&& typeof c.type === 'string'
|
|
451
|
+
&& isProps(c.props))) return false;
|
|
452
|
+
uv(3);
|
|
453
|
+
uv(c.id);
|
|
454
|
+
sym(c.type);
|
|
455
|
+
props(c.props);
|
|
456
|
+
return true;
|
|
457
|
+
}
|
|
458
|
+
const K_op_insert = ["op", "parent", "id", "before"];
|
|
459
|
+
/** "insert" = 4 */
|
|
460
|
+
function op_insert(c) {
|
|
461
|
+
if (!(keys(c, K_op_insert)
|
|
462
|
+
&& (c.parent === null || isUint(c.parent))
|
|
463
|
+
&& isUint(c.id)
|
|
464
|
+
&& (c.before === null || isUint(c.before)))) return false;
|
|
465
|
+
uv(4);
|
|
466
|
+
uv(c.parent === null ? 0 : c.parent + 1);
|
|
467
|
+
uv(c.id);
|
|
468
|
+
uv(c.before === null ? 0 : c.before + 1);
|
|
469
|
+
return true;
|
|
470
|
+
}
|
|
471
|
+
const K_op_move = ["op", "parent", "id", "before"];
|
|
472
|
+
/** "move" = 5 */
|
|
473
|
+
function op_move(c) {
|
|
474
|
+
if (!(keys(c, K_op_move)
|
|
475
|
+
&& (c.parent === null || isUint(c.parent))
|
|
476
|
+
&& isUint(c.id)
|
|
477
|
+
&& (c.before === null || isUint(c.before)))) return false;
|
|
478
|
+
uv(5);
|
|
479
|
+
uv(c.parent === null ? 0 : c.parent + 1);
|
|
480
|
+
uv(c.id);
|
|
481
|
+
uv(c.before === null ? 0 : c.before + 1);
|
|
482
|
+
return true;
|
|
483
|
+
}
|
|
484
|
+
const K_op_remove = ["op", "parent", "id"];
|
|
485
|
+
/** "remove" = 6 */
|
|
486
|
+
function op_remove(c) {
|
|
487
|
+
if (!(keys(c, K_op_remove)
|
|
488
|
+
&& (c.parent === null || isUint(c.parent))
|
|
489
|
+
&& isUint(c.id))) return false;
|
|
490
|
+
uv(6);
|
|
491
|
+
uv(c.parent === null ? 0 : c.parent + 1);
|
|
492
|
+
uv(c.id);
|
|
493
|
+
return true;
|
|
494
|
+
}
|
|
495
|
+
const K_op_destroy = ["op", "id"];
|
|
496
|
+
/** "destroy" = 7 */
|
|
497
|
+
function op_destroy(c) {
|
|
498
|
+
if (!(keys(c, K_op_destroy)
|
|
499
|
+
&& isUint(c.id))) return false;
|
|
500
|
+
uv(7);
|
|
501
|
+
uv(c.id);
|
|
502
|
+
return true;
|
|
503
|
+
}
|
|
504
|
+
const K_op_event = ["op", "id", "type", "listener"];
|
|
505
|
+
/** "event" = 8 */
|
|
506
|
+
function op_event(c) {
|
|
507
|
+
if (!(keys(c, K_op_event)
|
|
508
|
+
&& isUint(c.id)
|
|
509
|
+
&& typeof c.type === 'string'
|
|
510
|
+
&& (c.listener === null || c_Listener(c.listener)))) return false;
|
|
511
|
+
uv(8);
|
|
512
|
+
uv(c.id);
|
|
513
|
+
sym(c.type);
|
|
514
|
+
if (c.listener === null) uv(0); else { uv(1); w_Listener(c.listener); }
|
|
515
|
+
return true;
|
|
516
|
+
}
|
|
517
|
+
const K_op_visibility = ["op", "id", "state"];
|
|
518
|
+
/** "visibility" = 9 */
|
|
519
|
+
function op_visibility(c) {
|
|
520
|
+
if (!(keys(c, K_op_visibility)
|
|
521
|
+
&& isUint(c.id)
|
|
522
|
+
&& typeof c.state === 'string')) return false;
|
|
523
|
+
uv(9);
|
|
524
|
+
uv(c.id);
|
|
525
|
+
sym(c.state);
|
|
526
|
+
return true;
|
|
527
|
+
}
|
|
528
|
+
const K_op_mount_template_run = ["op", "parent", "before", "program", "firstId", "firstListenerId", "count", "values"];
|
|
529
|
+
/** "mount-template-run" = 10 */
|
|
530
|
+
function op_mount_template_run(c) {
|
|
531
|
+
if (!(keys(c, K_op_mount_template_run)
|
|
532
|
+
&& (c.parent === null || isUint(c.parent))
|
|
533
|
+
&& (c.before === null || isUint(c.before))
|
|
534
|
+
&& i_Program(c.program)
|
|
535
|
+
&& isUint(c.firstId)
|
|
536
|
+
&& (c.firstListenerId === null || isUint(c.firstListenerId))
|
|
537
|
+
&& isUint(c.count)
|
|
538
|
+
&& Array.isArray(c.values))) return false;
|
|
539
|
+
uv(10);
|
|
540
|
+
uv(c.parent === null ? 0 : c.parent + 1);
|
|
541
|
+
uv(c.before === null ? 0 : c.before + 1);
|
|
542
|
+
intern_Program(c.program);
|
|
543
|
+
uv(c.firstId);
|
|
544
|
+
uv(c.firstListenerId === null ? 0 : c.firstListenerId + 1);
|
|
545
|
+
uv(c.count);
|
|
546
|
+
slots(c.values, c.program);
|
|
547
|
+
return true;
|
|
548
|
+
}
|
|
549
|
+
const K_op_mount_template_range = ["op", "parent", "before", "program", "firstId", "values", "firstListenerId"];
|
|
550
|
+
/** "mount-template-range" = 11 */
|
|
551
|
+
function op_mount_template_range(c) {
|
|
552
|
+
if (!(keys(c, K_op_mount_template_range)
|
|
553
|
+
&& (c.parent === null || isUint(c.parent))
|
|
554
|
+
&& (c.before === null || isUint(c.before))
|
|
555
|
+
&& i_Program(c.program)
|
|
556
|
+
&& isUint(c.firstId)
|
|
557
|
+
&& Array.isArray(c.values)
|
|
558
|
+
&& (c.firstListenerId === null || isUint(c.firstListenerId)))) return false;
|
|
559
|
+
uv(11);
|
|
560
|
+
uv(c.parent === null ? 0 : c.parent + 1);
|
|
561
|
+
uv(c.before === null ? 0 : c.before + 1);
|
|
562
|
+
intern_Program(c.program);
|
|
563
|
+
uv(c.firstId);
|
|
564
|
+
slots(c.values, c.program);
|
|
565
|
+
uv(c.firstListenerId === null ? 0 : c.firstListenerId + 1);
|
|
566
|
+
return true;
|
|
567
|
+
}
|
|
568
|
+
const K_op_mount_template = ["op", "parent", "before", "shape", "nodes"];
|
|
569
|
+
/** "mount-template" = 12 */
|
|
570
|
+
function op_mount_template(c) {
|
|
571
|
+
if (!(keys(c, K_op_mount_template)
|
|
572
|
+
&& (c.parent === null || isUint(c.parent))
|
|
573
|
+
&& (c.before === null || isUint(c.before))
|
|
574
|
+
&& listOf(c.shape, c_ShapeNode)
|
|
575
|
+
&& listOf(c.nodes, c_TemplateNode))) return false;
|
|
576
|
+
uv(12);
|
|
577
|
+
uv(c.parent === null ? 0 : c.parent + 1);
|
|
578
|
+
uv(c.before === null ? 0 : c.before + 1);
|
|
579
|
+
{ const l = c.shape; const n = l.length; uv(n); for (let i = 0; i < n; i++) w_ShapeNode(l[i]); }
|
|
580
|
+
{ const l = c.nodes; const n = l.length; uv(n); for (let i = 0; i < n; i++) w_TemplateNode(l[i]); }
|
|
581
|
+
return true;
|
|
582
|
+
}
|
|
583
|
+
const K_op_set_transform = ["op", "id", "transform"];
|
|
584
|
+
/** "set-transform" = 13 */
|
|
585
|
+
function op_set_transform(c) {
|
|
586
|
+
if (!(keys(c, K_op_set_transform)
|
|
587
|
+
&& isUint(c.id)
|
|
588
|
+
&& isTransform(c.transform))) return false;
|
|
589
|
+
uv(13);
|
|
590
|
+
uv(c.id);
|
|
591
|
+
transform(c.transform);
|
|
592
|
+
return true;
|
|
593
|
+
}
|
|
594
|
+
const K_batch = ["renderer", "version", "commands"];
|
|
595
|
+
function header(batch) {
|
|
596
|
+
if (!(batch !== null && typeof batch === 'object'
|
|
597
|
+
&& keys(batch, K_batch)
|
|
598
|
+
&& typeof batch.renderer === 'string'
|
|
599
|
+
&& isUint(batch.version)
|
|
600
|
+
&& Array.isArray(batch.commands))) return false;
|
|
601
|
+
uv(0);
|
|
602
|
+
sym(batch.renderer);
|
|
603
|
+
uv(batch.version);
|
|
604
|
+
return true;
|
|
605
|
+
}
|
|
606
|
+
function command(c) {
|
|
607
|
+
if (c === null || typeof c !== 'object') return false;
|
|
608
|
+
switch (c.op) {
|
|
609
|
+
case "create": return op_create(c);
|
|
610
|
+
case "update": return op_update(c);
|
|
611
|
+
case "recreate": return op_recreate(c);
|
|
612
|
+
case "insert": return op_insert(c);
|
|
613
|
+
case "move": return op_move(c);
|
|
614
|
+
case "remove": return op_remove(c);
|
|
615
|
+
case "destroy": return op_destroy(c);
|
|
616
|
+
case "event": return op_event(c);
|
|
617
|
+
case "visibility": return op_visibility(c);
|
|
618
|
+
case "mount-template-run": return op_mount_template_run(c);
|
|
619
|
+
case "mount-template-range": return op_mount_template_range(c);
|
|
620
|
+
case "mount-template": return op_mount_template(c);
|
|
621
|
+
case "set-transform": return op_set_transform(c);
|
|
622
|
+
default: return false;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
function rollback() {
|
|
627
|
+
for (const s of defined) strings.delete(s);
|
|
628
|
+
stringCount -= defined.length;
|
|
629
|
+
defined = [];
|
|
630
|
+
for (let t = 0; t < TABLES; t++) {
|
|
631
|
+
for (const x of tableDefined[t]) tableMaps[t].delete(x);
|
|
632
|
+
tableCounts[t] -= tableDefined[t].length;
|
|
633
|
+
tableDefined[t] = [];
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
/** Encodes one batch. Its definitions stay unless rollback() runs before the next encode. */
|
|
637
|
+
function encode(input) {
|
|
638
|
+
o = 0;
|
|
639
|
+
local.clear();
|
|
640
|
+
localCount = 0;
|
|
641
|
+
defined = [];
|
|
642
|
+
for (let t = 0; t < TABLES; t++) tableDefined[t] = [];
|
|
643
|
+
try {
|
|
644
|
+
view.setUint32(0, MAGIC, true);
|
|
645
|
+
view.setUint32(4, DIGEST_LO, true);
|
|
646
|
+
view.setUint32(8, DIGEST_HI, true);
|
|
647
|
+
o = 12;
|
|
648
|
+
uv(stringCount);
|
|
649
|
+
for (let t = 0; t < TABLES; t++) uv(tableCounts[t]);
|
|
650
|
+
const batch = normalize(input, '');
|
|
651
|
+
if (!header(batch)) {
|
|
652
|
+
uv(1);
|
|
653
|
+
val(batch, 0, false);
|
|
654
|
+
} else {
|
|
655
|
+
const commands = batch.commands;
|
|
656
|
+
const n = commands.length;
|
|
657
|
+
uv(n);
|
|
658
|
+
for (let i = 0; i < n; i++) {
|
|
659
|
+
const c = normalize(commands[i], i);
|
|
660
|
+
if (command(c)) continue;
|
|
661
|
+
// Not a typed record: the command as a value (op 0).
|
|
662
|
+
uv(0);
|
|
663
|
+
if (omitted(c)) uv(0);
|
|
664
|
+
else val(c, 1, false);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
} catch (e) {
|
|
668
|
+
rollback();
|
|
669
|
+
throw e;
|
|
670
|
+
}
|
|
671
|
+
return bytes.buffer.slice(0, o);
|
|
672
|
+
}
|
|
673
|
+
return { encode, rollback };
|
|
674
|
+
}
|