Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
0fbf92c
feat: Add a reader for single file archives.
hoophalab Mar 4, 2026
9789b28
new clp commit
hoophalab Mar 5, 2026
fcaf511
remove comment
hoophalab Mar 5, 2026
9b83fe7
add test files
hoophalab Mar 8, 2026
5e4f579
Update to use result based API
Bill-hbrhbr Mar 9, 2026
fabc2ad
go back to using non-result return type for get_event_count
Bill-hbrhbr Mar 11, 2026
89b9ce5
Add new test file and new binding for file info and tests
Bill-hbrhbr Mar 11, 2026
cfa1cc6
Merge the new FIleInfo changes
Bill-hbrhbr Mar 11, 2026
7f5bd78
upstream
hoophalab Mar 12, 2026
2d52229
deps
hoophalab Mar 12, 2026
8abbf1b
revert deps
hoophalab Mar 12, 2026
54f4925
use short commit id; remove duplicated cmake flags
hoophalab Mar 12, 2026
c042683
bind file info API and add tests
Bill-hbrhbr Mar 13, 2026
1359421
lint 21.1.x cpp
Bill-hbrhbr Mar 13, 2026
aa06ec9
remove extra zstd
Bill-hbrhbr Mar 13, 2026
5c928f1
Cleanup CMakeLists.txt
Bill-hbrhbr Mar 14, 2026
a7d1a5d
Improve logging of CLP_S side errors
Bill-hbrhbr Mar 14, 2026
2db9082
Fix type_utils header import
Bill-hbrhbr Mar 14, 2026
20471b2
Extract common path var
Bill-hbrhbr Mar 14, 2026
46b6bcb
comments
hoophalab Mar 13, 2026
1db28ca
second pass
hoophalab Mar 14, 2026
58187fb
pin clang-format and apply fixes
Bill-hbrhbr Mar 14, 2026
657fd7f
Fix lint CI
Bill-hbrhbr Mar 14, 2026
ae06c68
Try checking cpp static diff
Bill-hbrhbr Mar 14, 2026
bd13d29
Lint each file type individually
Bill-hbrhbr Mar 14, 2026
6ca13b4
Move binding type registration into central module as well
Bill-hbrhbr Mar 15, 2026
df798da
lint fixes clang-tidy
Bill-hbrhbr Mar 15, 2026
ba8947f
minor touch up
Bill-hbrhbr Mar 15, 2026
57f3a1c
Merge branch 'initial-sfa-pr' into sfa-reader-mar15
Bill-hbrhbr Mar 16, 2026
7f570af
Merge branch 'pin-clang-format-v21' into sfa-reader-mar15
Bill-hbrhbr Mar 16, 2026
41af1f5
cpp lint fix
Bill-hbrhbr Mar 16, 2026
7e42123
js lint fix
Bill-hbrhbr Mar 16, 2026
8b57ad4
Use explicit binding types for SfaReader API return
Bill-hbrhbr Mar 16, 2026
be7576b
Bind decode
Bill-hbrhbr Mar 16, 2026
a6e1aa2
LogEvent and ClpArchiveReader
Bill-hbrhbr Mar 16, 2026
4aee6b6
Add jsdoc
Bill-hbrhbr Mar 16, 2026
4e971d5
add docs
Bill-hbrhbr Mar 16, 2026
2d8331a
remove jsdoc
Bill-hbrhbr Mar 16, 2026
da10671
INstall npm serve
Bill-hbrhbr Mar 16, 2026
386bcf8
Upgrade eslint tsdoc to latest
Bill-hbrhbr Mar 16, 2026
fa09919
Improve config
Bill-hbrhbr Mar 16, 2026
35c9b39
Unstage undeterministic docs/
Bill-hbrhbr Mar 16, 2026
253c801
Add task flow for building and serving docs
Bill-hbrhbr Mar 16, 2026
885dbec
Add README for docs
Bill-hbrhbr Mar 16, 2026
c8d26e1
lint fix
Bill-hbrhbr Mar 16, 2026
e44ce28
Remove conflicting tsdoc
Bill-hbrhbr Mar 16, 2026
ffabb3f
change API name to decode ALL
Bill-hbrhbr Mar 16, 2026
60c956d
Update CLP version
Bill-hbrhbr Mar 16, 2026
757232d
default serve docs path
Bill-hbrhbr Mar 16, 2026
04eba1f
Reword module docstring
Bill-hbrhbr Mar 16, 2026
20b39cd
update clp version
Bill-hbrhbr Mar 16, 2026
7ff71b4
Rename test file
Bill-hbrhbr Mar 16, 2026
da8e043
Add timestamp key checking
Bill-hbrhbr Mar 18, 2026
d0b93e0
lint fix
Bill-hbrhbr Mar 18, 2026
a62c360
Add sfa typing and import path to npm package
Bill-hbrhbr Mar 18, 2026
3721498
Switch to use internal import for wasm artifacts
Bill-hbrhbr Mar 18, 2026
643ef8b
remove remaining dist imports
Bill-hbrhbr Mar 18, 2026
9950023
fix taskfile
Bill-hbrhbr Mar 18, 2026
a993330
Bump types/node version
Bill-hbrhbr Mar 18, 2026
1dc0891
Working change to preload module during ClpArchiveReader construction
Bill-hbrhbr Mar 18, 2026
87d3355
js lint fix
Bill-hbrhbr Mar 18, 2026
b8f167a
Install typedoc and serve
Bill-hbrhbr Mar 18, 2026
e065210
Add task and CI workflow
Bill-hbrhbr Mar 18, 2026
e2aa7ab
Add harmless run once to all main task workflows
Bill-hbrhbr Mar 18, 2026
f533046
satisfy markdown lint
Bill-hbrhbr Mar 18, 2026
bc3c5bb
Update .github/workflows/docs.yaml
Bill-hbrhbr Mar 18, 2026
0a212f4
Remove unused tsdoc
Bill-hbrhbr Mar 18, 2026
494f303
ci(publish-to-npm): Switch to OIDC trusted publishing; Update and pin…
junhaoliao Mar 19, 2026
81bca18
feat(sfa): Add initial single-file archive reader bindings; Extract s…
hoophalab Mar 16, 2026
9cd69dc
Merge branch 'main' into sfa-reader-mar16
Bill-hbrhbr Mar 19, 2026
e69a616
Fix typo
Bill-hbrhbr Mar 19, 2026
4a4fd7a
chore: Upgrade version for 0.7.0-beta.1 release.
Bill-hbrhbr Mar 19, 2026
990f828
Merge branch 'main' into docs
Bill-hbrhbr Mar 19, 2026
e11d078
Add GH page generation workflow
Bill-hbrhbr Mar 19, 2026
d9bf588
Change docs:build to docs:site
Bill-hbrhbr Mar 19, 2026
a69c734
Merge branch 'main' into sfa-reader-mar16
Bill-hbrhbr Mar 20, 2026
b42a1d0
Remove Gh pages workflow and use typedoc.json instead of jsonc
Bill-hbrhbr Mar 20, 2026
6ee8509
Merge branch 'main' into docs
junhaoliao Mar 22, 2026
bbe878a
Merge branch 'main' into docs
Bill-hbrhbr Mar 23, 2026
00c168e
Move emsdk into its own deps module
Bill-hbrhbr Mar 23, 2026
c8a8cf5
Reuse npm workflow
Bill-hbrhbr Mar 23, 2026
1618955
Change global default task to package
Bill-hbrhbr Mar 23, 2026
d9954c8
Move node-modules into deps as well and make main taskfile tasks stri…
Bill-hbrhbr Mar 23, 2026
5e4dd71
move emsdk to toolchains
Bill-hbrhbr Mar 23, 2026
e8bdae7
Move out node-modules
Bill-hbrhbr Mar 23, 2026
3b517e0
revert deps folder change
Bill-hbrhbr Mar 23, 2026
eb35c7f
Minor fixes
Bill-hbrhbr Mar 23, 2026
80d5269
Add new flag
Bill-hbrhbr Mar 23, 2026
35a02d1
Address coderabbit concern
Bill-hbrhbr Mar 23, 2026
b2e15f2
Merge branch 'fix-emsdk-taskfile' into docs
Bill-hbrhbr Mar 23, 2026
730255b
Upgrade and pin emsdk version to 5.0.4
Bill-hbrhbr Mar 24, 2026
dfc66e0
downgrade to pre v5 release
Bill-hbrhbr Mar 24, 2026
432710e
Update sources section
Bill-hbrhbr Mar 24, 2026
9369c92
Merge branch 'fix-emsdk-taskfile' into docs
Bill-hbrhbr Mar 24, 2026
2270029
Merge branch 'main' into sfa-reader-mar16
Bill-hbrhbr Mar 24, 2026
483d4e5
Merge branch 'fix-emsdk-taskfile' into sfa-reader-mar16
Bill-hbrhbr Mar 24, 2026
f17263c
Merge branch 'docs' into sfa-reader-mar16
Bill-hbrhbr Mar 24, 2026
0fdd0b7
Merge branch 'main' into sfa-reader-mar16
Bill-hbrhbr Mar 27, 2026
f49cb76
Merge branch 'main' into sfa-reader-mar16
Bill-hbrhbr Apr 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if("${CLP_FFI_JS_PACKAGE_JSON_CONTENT}" MATCHES "\"name\":[ ]*\"([^\"]+)\"")
else()
set(CLP_FFI_JS_PROJECT_NAME "clp-ffi-js")
endif()
if("${CLP_FFI_JS_PACKAGE_JSON_CONTENT}" MATCHES "\"version\":[ ]*\"([^\"]+)\"")
if("${CLP_FFI_JS_PACKAGE_JSON_CONTENT}" MATCHES "\"version\":[ ]*\"([0-9]+\\.[0-9]+\\.[0-9]+)")
set(CLP_FFI_JS_VERSION "${CMAKE_MATCH_1}")
else()
set(CLP_FFI_JS_VERSION "0.0.0")
Expand Down
2 changes: 2 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const EslintConfig = [
ignores: [
"build/",
"dist/",
"docs/",
"node_modules/",
"test/",
],
},
CommonConfig,
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clp-ffi-js",
"version": "0.6.1",
"version": "0.7.0-beta.1",
"description": "clp-ffi-js is a JavaScript FFI library for CLP.",
"author": "YScope Inc. <dev@yscope.com>",
"license": "Apache-2.0",
Expand Down Expand Up @@ -55,7 +55,7 @@
}
},
"devDependencies": {
"@types/node": "^22.19.9",
"@types/node": "^22.19.15",
"@vitest/browser-playwright": "^4.0.18",
"eslint": "^9.39.2",
"eslint-config-yscope": "^1.1.2",
Expand Down
3 changes: 2 additions & 1 deletion src/clp_ffi_js/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include <array>
#include <cstdint>
#include <string_view>
#include <type_utils.hpp>

#include <clp/type_utils.hpp>

namespace clp_ffi_js {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/clp_ffi_js/ir/StructuredIrUnitHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
#include <optional>
#include <string>
#include <string_view>
#include <type_utils.hpp>
#include <utility>

#include <clp/ffi/ir_stream/decoding_methods.hpp>
#include <clp/ffi/SchemaTree.hpp>
#include <clp/ffi/Value.hpp>
#include <clp/ir/types.hpp>
#include <clp/time_types.hpp>
#include <clp/type_utils.hpp>
#include <emscripten/val.h>
#include <spdlog/spdlog.h>

Expand Down
21 changes: 21 additions & 0 deletions src/clp_ffi_js/sfa/ClpArchiveReader.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {LogEvent} from "./LogEvent.js";
import {getModule} from "./module.js";
import type {FileInfo} from "./types.js";

Expand Down Expand Up @@ -65,6 +66,26 @@ class ClpArchiveReader {
return this.#getWasmReader().getFileInfos();
}

/**
* Decodes all log events in global log-event-index order.
*
* @return Decoded log events.
* @throws {Error} If the reader has been closed.
*/
decodeAll (): LogEvent[] {
return (this.#getWasmReader().decodeAll() as Array<{
logEventIdx: bigint;
message: string;
timestamp: bigint;
}>).map((rawEvent) => {
return new LogEvent(
rawEvent.logEventIdx,
rawEvent.timestamp,
rawEvent.message
);
});
}

/**
* Releases the underlying WASM resources. After calling this method, the reader is no longer
* usable and any subsequent method calls will throw.
Expand Down
39 changes: 39 additions & 0 deletions src/clp_ffi_js/sfa/LogEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type {FieldValue} from "./types.js";


/**
* Single log event from a CLP archive.
*/
class LogEvent {
readonly logEventIdx: bigint;

readonly timestamp: bigint;

readonly message: string;

/**
* @param logEventIdx Global log event index.
* @param timestamp Epoch timestamp.
* @param message Serialized message string.
*/
constructor (logEventIdx: bigint, timestamp: bigint, message: string) {
this.logEventIdx = logEventIdx;
this.timestamp = timestamp;
this.message = message;
}

/**
* Returns the key-value pairs of this log event by parsing the message as JSON.
*
* @return The key-value pairs, or null if the message is not valid JSON.
*/
getKvPairs (): Readonly<{[key: string]: FieldValue}> | null {
try {
return JSON.parse(this.message) as {[key: string]: FieldValue};
} catch {
return null;
}
}
}

export {LogEvent};
30 changes: 29 additions & 1 deletion src/clp_ffi_js/sfa/SfaReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,40 @@ auto SfaReader::get_file_infos() const -> FileInfoArrayTsType {
}
return FileInfoArrayTsType{file_infos};
}

auto SfaReader::decode_all() -> LogEventArrayTsType {
auto decoded_result{m_reader.decode_all()};
if (decoded_result.has_error()) {
auto const error{decoded_result.error()};
auto const err_msg{fmt::format(
"Failed to decode SFA archive: {} - {}.",
error.category().name(),
error.message()
)};
SPDLOG_ERROR("{}", err_msg);
throw std::runtime_error{err_msg};
}

auto decoded_events{emscripten::val::array()};
for (auto const& event : decoded_result.value()) {
auto entry{emscripten::val::object()};
entry.set("logEventIdx", emscripten::val(event.get_log_event_idx()));
entry.set("timestamp", emscripten::val(event.get_timestamp()));
entry.set("message", emscripten::val(event.get_message()));
decoded_events.call<void>("push", entry);
}
return LogEventArrayTsType{decoded_events};
}
} // namespace clp_ffi_js::sfa

EMSCRIPTEN_BINDINGS(SfaReader) {
emscripten::register_type<clp_ffi_js::sfa::FileInfoArrayTsType>(
"Array<{fileName: string, logEventIdxStart: bigint, logEventIdxEnd: bigint, "
"logEventCount: bigint}>"
);
emscripten::register_type<clp_ffi_js::sfa::LogEventArrayTsType>(
"Array<{logEventIdx: bigint, timestamp: bigint, message: string}>"
);

emscripten::class_<clp_ffi_js::sfa::SfaReader>("ClpSfaReader")
.constructor(
Expand All @@ -81,5 +108,6 @@ EMSCRIPTEN_BINDINGS(SfaReader) {
)
.function("getEventCount", &clp_ffi_js::sfa::SfaReader::get_event_count)
.function("getFileNames", &clp_ffi_js::sfa::SfaReader::get_file_names)
.function("getFileInfos", &clp_ffi_js::sfa::SfaReader::get_file_infos);
.function("getFileInfos", &clp_ffi_js::sfa::SfaReader::get_file_infos)
.function("decodeAll", &clp_ffi_js::sfa::SfaReader::decode_all);
}
3 changes: 3 additions & 0 deletions src/clp_ffi_js/sfa/SfaReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace clp_ffi_js::sfa {
EMSCRIPTEN_DECLARE_VAL_TYPE(FileInfoArrayTsType);
EMSCRIPTEN_DECLARE_VAL_TYPE(LogEventArrayTsType);

class SfaReader {
public:
Expand All @@ -31,6 +32,8 @@ class SfaReader {

[[nodiscard]] auto get_file_infos() const -> FileInfoArrayTsType;

[[nodiscard]] auto decode_all() -> LogEventArrayTsType;

private:
explicit SfaReader(clp_s::ffi::sfa::ClpArchiveReader&& reader) : m_reader(std::move(reader)) {}

Expand Down
3 changes: 2 additions & 1 deletion src/clp_ffi_js/sfa/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export {ClpArchiveReader} from "./ClpArchiveReader.js";
export type {FileInfo} from "./types.js";
export {LogEvent} from "./LogEvent.js";
export type {FieldValue, FileInfo} from "./types.js";
13 changes: 12 additions & 1 deletion src/clp_ffi_js/sfa/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,15 @@ interface FileInfo {
logEventCount: bigint;
}

export type {FileInfo};
type FieldValue =
number |
string |
boolean |
null |
{[key: string]: FieldValue} |
FieldValue[];

export type {
FieldValue,
FileInfo,
};
43 changes: 43 additions & 0 deletions src/clp_ffi_js/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import NodeModuleFactory, {type MainModule} from "#clp-ffi-js/node";
import WorkerModuleFactory from "#clp-ffi-js/worker";


/**
* Detects whether the current runtime is Node.js.
*
* @return True if running in Node.js.
*/
const isNodeRuntime = (): boolean => {
const maybeWindow = (globalThis as {window?: unknown}).window;
if ("undefined" !== typeof maybeWindow) {
return false;
}

const maybeProcess = (globalThis as {process?: {versions?: {node?: unknown}}}).process;
return "string" === typeof maybeProcess?.versions?.node;
};

let mainModulePromise: Promise<MainModule> | null = null;

/**
* Returns the shared CLP FFI module instance, initializing it lazily once.
*
* @return A cached `MainModule` promise.
*/
const getMainModule = (): Promise<MainModule> => {
if (null !== mainModulePromise) {
return mainModulePromise;
}

const moduleFactory = (
true === isNodeRuntime() ?
NodeModuleFactory :
WorkerModuleFactory
) as () => Promise<MainModule>;

mainModulePromise = moduleFactory();

return mainModulePromise;
};

export {getMainModule};
1 change: 1 addition & 0 deletions taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ tasks:
deps: ["deps"]
cmd: |-
cmake \
-DCLP_FFI_JS_ENABLE_SFA_READER_BINDING=ON \
-DCLP_FFI_JS_SUPPORTED_ENVIRONMENTS="{{.G_CLP_FFI_JS_ENV_NAMES | join ";"}}" \
-DCMAKE_TOOLCHAIN_FILE="{{.G_EMSCRIPTEN_CMAKE_TOOLCHAIN_FILE}}" \
-S "{{.ROOT_DIR}}" \
Expand Down
4 changes: 2 additions & 2 deletions taskfiles/deps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ tasks:
cmds:
- task: ":utils:remote:download-and-extract-tar"
vars:
FILE_SHA256: "aedfc75767a4b5fe3a970e3c8398fc909bec27f6b6f8e62a78d8344625e3f66e"
FILE_SHA256: "248ea1fc4d54cad6433126ff39be649ba40968ef0042a6c977b4a447ca4bf684"
OUTPUT_DIR: "{{.OUTPUT_DIR}}"
URL: "https://github.com/y-scope/clp/archive/f9b9cc0.tar.gz"
URL: "https://github.com/y-scope/clp/archive/ec74acc.tar.gz"
- >-
echo "set(
CLP_FFI_JS_CLP_SOURCE_DIRECTORY \"{{.OUTPUT_DIR}}\"
Expand Down
Loading
Loading