Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 16 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ let messengerPlugin: Target = .target(
resources: [.process("Resources")]
)

let profilerPlugin: Target = .target(
name: "PlayerUIDevToolsProfilerDevtoolsPlugin",
dependencies: [
playerUIDependency,
playerUISwiftUIDependency
],
path: "devtools/plugins/profiler/ios",
exclude: excluded,
resources: [.process("Resources")]
)

// --- END DECLARATIONS ---

// This is the Package.swift for our SPM release.
Expand All @@ -42,11 +53,15 @@ let package = Package(
.library(
name: messengerPlugin.name,
targets: [messengerPlugin.name]
),
.library(
name: profilerPlugin.name,
targets: [profilerPlugin.name]
)
],
dependencies: [
.package(url: "https://github.com/player-ui/playerui-swift-package.git", from: "0.11.2"),
.package(url:"https://github.com/chiragramani/SwiftFlipper.git", from: "0.1.0"),
],
targets: [messengerPlugin]
targets: [messengerPlugin, profilerPlugin]
)
3 changes: 3 additions & 0 deletions devtools/plugin/core/src/helpers/getNowTime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const getNowTime = globalThis.performance
? () => globalThis.performance.now()
: () => Date.now();
Comment on lines +1 to +3
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

performance isn't available on the ios and kotlin integrations, so it's preferred for accuracy but Date.now still works.

1 change: 1 addition & 0 deletions devtools/plugin/core/src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { generateUUID } from "./uuid";
export { genDataChangeTransaction } from "./genDataChangeTransaction";
export { getNowTime } from "./getNowTime";
8 changes: 3 additions & 5 deletions devtools/plugin/core/src/helpers/uuid.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { getNowTime } from "./getNowTime";

// TODO: Either polyfill crypto or use this (pulled from SO)
export function generateUUID(): string {
// Public Domain/MIT
let d = new Date().getTime(); //Timestamp
let d2 =
(typeof performance !== "undefined" &&
performance.now &&
performance.now() * 1000) ||
0; //Time in microseconds since page-load or 0 if unsupported
let d2 = getNowTime() * 1000;
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
let r = Math.random() * 16; //random number between 0 and 16
if (d > 0) {
Expand Down
28 changes: 28 additions & 0 deletions devtools/plugins/profiler/core/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@rules_player//javascript:defs.bzl", "js_pipeline")
load("//helpers:defs.bzl", "NATIVE_BUILD_DEPS", "tsup_config", "vitest_config")

npm_link_all_packages(name = "node_modules")

tsup_config(name = "tsup_config")

vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-devtools/profiler-plugin",
build_deps = NATIVE_BUILD_DEPS,
native_bundle = "ProfilerDevtoolsPlugin",
deps = [
":node_modules/@player-devtools/messenger",
":node_modules/@player-devtools/plugin",
":node_modules/@player-devtools/types",
"//:node_modules/@devtools-ui/plugin",
"//:node_modules/@player-ui/player",
"//:node_modules/@types/uuid",
"//:node_modules/dequal",
"//:node_modules/dset",
"//:node_modules/immer",
"//:node_modules/uuid",
"//:node_modules/tapable-ts",
],
)
10 changes: 10 additions & 0 deletions devtools/plugins/profiler/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@player-devtools/profiler-plugin",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"dependencies": {
"@player-devtools/messenger": "workspace:*",
"@player-devtools/plugin": "workspace:*",
"@player-devtools/types": "workspace:*"
}
}
Loading