Moving source files around to make it easier to consume clarity-tools as a package (#6)

* Move source files to src directory

* Updating build instructions

* Updating .gitignore

* Removing npm-debug.log

* Updating package.json

* Change entry point in package.json
This commit is contained in:
Sarvesh Nagpal 2017-07-28 15:50:40 -07:00 коммит произвёл GitHub
Родитель f70906242c
Коммит f25c0e5652
35 изменённых файлов: 33 добавлений и 347 удалений

5
.gitignore поставляемый
Просмотреть файл

@ -1,4 +1,7 @@
data.json
node_modules
build
env.bat
env.bat
visualization
extension
npm-debug.log

14
.npmignore Normal file
Просмотреть файл

@ -0,0 +1,14 @@
# Visual Studio Code temporary files
.vscode/
# npm packages
node_modules
# npm logs
npm-debug.log*
# src files
src
# rollup-plugins-typescript2
.rpt2_cache

Просмотреть файл

@ -4,6 +4,7 @@
"description": "A collection of tools to help visualize the data collected from clarity-js package",
"author": "Microsoft Corp.",
"license": "MIT",
"main": "visualization/uncompress.js",
"keywords": [
"clarity",
"Microsoft",
@ -24,7 +25,7 @@
},
"dependencies": {
"clarity-js": "^0.1.8",
"material-ui": "^0.17.0",
"material-ui": "0.17.4",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-redux": "^5.0.3",
@ -50,9 +51,9 @@
},
"scripts": {
"compile": "node_modules/.bin/tsc -p ./",
"bundle:content": "node_modules/.bin/browserify ./build/extension/instrument.js > ./build/extension/content.js",
"bundle:visualization": "node_modules/.bin/browserify ./build/extension/app.js > ./build/extension/clarity.js",
"binplace:extension": "node_modules/.bin/copyfiles -f ./extension/*.html ./extension/manifest.json ./extension/*.png ./build/extension/",
"bundle:content": "node_modules/.bin/browserify ./extension/instrument.js > ./extension/content.js",
"bundle:visualization": "node_modules/.bin/browserify ./extension/app.js > ./extension/clarity.js",
"binplace:extension": "node_modules/.bin/copyfiles -f ./src/extension/*.html ./src/extension/manifest.json ./src/extension/*.png ./extension/",
"build": "npm run compile && npm run bundle:content && npm run binplace:extension && npm run bundle:visualization"
}
}

Просмотреть файл

Просмотреть файл

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 2.7 KiB

После

Ширина:  |  Высота:  |  Размер: 2.7 KiB

Просмотреть файл

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 3.0 KiB

После

Ширина:  |  Высота:  |  Размер: 3.0 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 8.0 KiB

После

Ширина:  |  Высота:  |  Размер: 8.0 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 6.4 KiB

После

Ширина:  |  Высота:  |  Размер: 6.4 KiB

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -1,4 +1,4 @@
/// <reference path="../clarity.d.ts" />
/// <reference path="../../../node_modules/clarity-js/clarity.d.ts" />
import { IParser } from "../components/Snapshot";
export default class Layout implements IParser {

Просмотреть файл

@ -1,4 +1,4 @@
/// <reference path="../clarity.d.ts" />
/// <reference path="../../../node_modules/clarity-js/clarity.d.ts" />
import { IParser } from "../components/Snapshot";
export default class Pointer implements IParser {

Просмотреть файл

@ -1,4 +1,4 @@
/// <reference path="../clarity.d.ts" />
/// <reference path="../../../node_modules/clarity-js/clarity.d.ts" />
import { IParser } from "../components/Snapshot";
export default class Viewport implements IParser {

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -14,14 +14,18 @@
"noLib": false,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": true,
"outDir": "./build/",
"rootDir": "./",
"outDir": "./",
"sourceMap": false,
"allowJs": true
},
"include":[
"src/**/*.ts",
"src/**/*.tsx"
],
"exclude": [
"node_modules",
"build"
"visualization",
"extension"
],
"compileOnSave": true,
"buildOnSave": false,

336
visualization/clarity.d.ts поставляемый
Просмотреть файл

@ -1,336 +0,0 @@
/* ##################################### */
/* ############ CONFIG ############# */
/* ##################################### */
interface IConfig {
// Endpoint, to which data will be uploaded
uploadUrl?: string;
// Each new event is going to delay data upload to server by this number of milliseconds
delay?: number;
// Maximum number of event bytes that Clarity can send in a single upload
batchLimit?: number;
// Maximum number of bytes that Clarity can send per page overall
totalLimit?: number;
// If set to false, text on the page will be masked with asterisks
showText?: boolean;
// If set to false, src of images won't be captured
showImages?: boolean;
// Maximum number of milliseconds, after which Clarity should yield the thread
// It is used to avoid freezing the page during large object serialization
timeToYield?: number;
// Send back instrumentation data, if set to true
instrument?: boolean;
// Pointer to the function which would be responsible for sending the data
// If left unspecified, raw payloads will be uploaded to the uploadUrl endpoint
uploadHandler?: UploadHandler;
// Setting to enable debug features (e.g. console.log statements)
debug?: boolean;
// Active plugins
plugins?: string[];
}
/* ##################################### */
/* ############# CORE ############## */
/* ##################################### */
declare const enum State {
Loaded,
Activated,
Unloaded
}
interface IPayload {
envelope: IEnvelope;
events: IEvent[];
}
interface IEnvelope {
clarityId: string;
impressionId: string;
url: string;
title: string;
version: string;
time: number;
sequenceNumber: number;
}
interface IEvent {
id: number; /* Event ID */
time: number; /* Time relative to page start */
type: string; /* Type of the event */
state: any;
}
interface IDroppedPayloadInfo {
payload: string;
xhrErrorState: IXhrErrorEventState;
}
interface IPlugin {
activate(): void;
teardown(): void;
reset(): void;
}
interface IEventBindingPair {
target: EventTarget;
listener: EventListener;
}
interface IBindingContainer {
[key: string]: IEventBindingPair[];
}
type UploadCallback = (status: number) => void;
type UploadHandler = (payload: string, onSuccess?: UploadCallback, onFailure?: UploadCallback) => void;
/* ##################################### */
/* ############ LAYOUT ############# */
/* ##################################### */
interface IShadowDomNode extends HTMLDivElement {
node: Node; /* Reference to the node in the real DOM */
layout: ILayoutState; /* Latest layout JSON */
ignore: boolean; /* Flag to avoid sending data for that node */
}
interface ILayoutRectangle {
x: number; /* X coordinate of the element */
y: number; /* Y coordinate of the element */
width: number; /* Width of the element */
height: number; /* Height of the element */
scrollX?: number; /* Scroll left of the element */
scrollY?: number; /* Scroll top of the element */
}
declare const enum Source {
Discover,
Mutation,
Scroll,
Input
}
declare const enum Action {
Insert,
Update,
Remove,
Move,
Ignore
}
interface IAttributes {
[key: string]: string;
}
// Generic storage of various data pieces that can be passed along with
// different layout events originating from different actions
interface ILayoutEventInfo {
node: Node;
source: Source;
action: Action;
time?: number;
}
interface ILayoutStateBase {
index: number; /* Index of the layout element */
source: Source; /* Source of discovery */
action: Action; /* Reflect the action with respect to DOM */
mutationSequence?: number; /* Sequence number of the mutation batch */
}
interface ILayoutState extends ILayoutStateBase {
parent: number; /* Index of the parent element */
tag: string; /* Tag name of the element */
previous: number; /* Index of the previous sibling, if known */
next: number; /* Index of the next sibling, if known */
}
interface IDoctypeLayoutState extends ILayoutState {
attributes: {
name: string;
publicId: string;
systemId: string;
};
}
interface IElementLayoutState extends ILayoutState {
attributes: IAttributes; /* Attributes associated with an element */
layout: ILayoutRectangle; /* Layout rectangle */
}
interface ITextLayoutState extends ILayoutState {
content: string;
}
interface IMutationEntry {
node: Node;
action: Action;
parent?: Node;
previous?: Node;
next?: Node;
}
// Interface to store some information about the initial state of the node
// in cases where mutation happens before we process the node for the first time.
// Stroring original values of the properties that can were mutated allows us to
// re-construct the initial state of the node even after mutation has happened.
interface INodePreUpdateInfo {
characterData?: string;
attributes?: IAttributes;
}
interface IShadowDomMutationSummary {
newNodes: IShadowDomNode[];
movedNodes: IShadowDomNode[];
removedNodes: IShadowDomNode[];
updatedNodes: IShadowDomNode[];
}
/* ##################################### */
/* ########### POINTER ############# */
/* ##################################### */
interface IPointerEvent extends IEvent {
state: IPointerState;
}
interface IPointerModule {
transform(evt: Event): IPointerState[];
}
/* Spec: https://www.w3.org/TR/pointerevents/#pointerevent-interface */
interface IPointerState {
index: number; /* Pointer ID */
event: string; /* Original event that is mapped to pointer event */
pointer: string; /* pointerType: mouse, pen, touch */
x: number; /* X-Axis */
y: number; /* Y-Axis */
width: number;
height: number;
pressure: number;
tiltX: number;
tiltY: number;
target: number; /* Layout index of the target element */
buttons: number;
}
/* ##################################### */
/* ########## VIEWPORT ############# */
/* ##################################### */
interface IViewportEvent extends IEvent {
state: IViewportState;
}
interface IViewportRectangle {
x: number; /* X coordinate of the element */
y: number; /* Y coordinate of the element */
width: number; /* Width of the element */
height: number; /* Height of the element */
}
interface IDocumentSize {
width: number; /* Document width */
height: number; /* Document height */
}
interface IViewportState {
viewport: IViewportRectangle; /* Viewport rectangle */
document: IDocumentSize; /* Document size */
dpi: number; /* DPI */
visibility: string; /* Visibility state of the page */
event: string; /* Source event */
}
/* ##################################### */
/* ####### INSTRUMENTATION ######### */
/* ##################################### */
declare const enum Instrumentation {
JsError,
MissingFeature,
XhrError,
TotalByteLimitExceeded,
Teardown,
ClarityAssertFailed,
ClarityDuplicated
}
interface IInstrumentationEventState {
type: Instrumentation;
}
interface IJsErrorEventState extends IInstrumentationEventState {
source: string;
message: string;
stack: string;
lineno: number;
colno: number;
}
interface IMissingFeatureEventState extends IInstrumentationEventState {
missingFeatures: string[];
}
interface IXhrErrorEventState extends IInstrumentationEventState {
requestStatus: number;
sequenceNumber: number;
compressedLength: number;
rawLength: number;
firstEventId: number;
lastEventId: number;
attemptNumber: number;
}
interface ITotalByteLimitExceededEventState extends IInstrumentationEventState {
bytes: number;
}
interface IClarityAssertFailedEventState extends IInstrumentationEventState {
source: string;
comment: string;
}
interface IClarityDuplicatedEventState extends IInstrumentationEventState {
currentImpressionId: string;
}
/* ##################################### */
/* ######### PERFORMANCE ########### */
/* ##################################### */
interface IPerformanceTiming extends PerformanceTiming {
// We send back all properties from performance.timing object
}
interface IPerformanceResourceTiming {
duration: number;
initiatorType: string;
startTime: number;
connectStart: number;
connectEnd: number;
requestStart: number;
responseStart: number;
responseEnd: number;
name: string;
transferSize?: number;
encodedBodySize?: number;
decodedBodySize?: number;
}
/* ##################################### */
/* ############ LIBRARY ############ */
/* ##################################### */
interface IClarity {
start(config?: IConfig): void;
stop(): void;
}