Skip to content

Commit

Permalink
Version 5.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jontyt committed Jul 10, 2024
1 parent ef8be1b commit d2db932
Show file tree
Hide file tree
Showing 25 changed files with 635 additions and 114 deletions.
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 5.1.0
* Revoke SDK token on logout
this improves on the previous behaviour where logging out would only purge tokens locally.

# 5.0.0
* Add automatic SDK local settings restore on template reload
* Upgrade node-fetch dependency to avoid annoying deprecation warning. #91
Expand Down
5 changes: 2 additions & 3 deletions common/embed/credit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLocalizedCreditTextAndUrl = exports.createFlourishCredit = void 0;
exports.createFlourishCredit = createFlourishCredit;
exports.getLocalizedCreditTextAndUrl = getLocalizedCreditTextAndUrl;
const localizations_1 = __importDefault(require("./localizations"));
function createFlourishCredit(credit_url, query_string, public_url, credit_text) {
credit_url = credit_url || "https://flourish.studio",
Expand All @@ -29,7 +30,6 @@ function createFlourishCredit(credit_url, query_string, public_url, credit_text)
a.appendChild(span);
return credit;
}
exports.createFlourishCredit = createFlourishCredit;
function getLocalizedCreditTextAndUrl(lang, credit_key) {
var credit_text, credit_url;
lang = lang || "en", credit_key = credit_key || "";
Expand All @@ -44,4 +44,3 @@ function getLocalizedCreditTextAndUrl(lang, credit_key) {
credit_url: credit_url
};
}
exports.getLocalizedCreditTextAndUrl = getLocalizedCreditTextAndUrl;
11 changes: 5 additions & 6 deletions common/embed/customer_analytics.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initCustomerAnalytics = exports.dispatchAnalyticsEvent = exports.removeAnalyticsListener = exports.addAnalyticsListener = exports.sendCustomerAnalyticsMessage = void 0;
exports.sendCustomerAnalyticsMessage = sendCustomerAnalyticsMessage;
exports.addAnalyticsListener = addAnalyticsListener;
exports.removeAnalyticsListener = removeAnalyticsListener;
exports.dispatchAnalyticsEvent = dispatchAnalyticsEvent;
exports.initCustomerAnalytics = initCustomerAnalytics;
// Embedded code - must work in IE
var enabled = false;
function getLocationData() {
Expand Down Expand Up @@ -52,14 +56,12 @@ function sendCustomerAnalyticsMessage(message) {
}
embedded_window.parent.postMessage(JSON.stringify(message_with_metadata), "*");
}
exports.sendCustomerAnalyticsMessage = sendCustomerAnalyticsMessage;
function addAnalyticsListener(callback) {
if (typeof callback !== "function") {
throw new Error("Analytics callback is not a function");
}
window.Flourish._analytics_listeners.push(callback);
}
exports.addAnalyticsListener = addAnalyticsListener;
function removeAnalyticsListener(callback) {
if (typeof callback !== "function") {
throw new Error("Analytics callback is not a function");
Expand All @@ -68,7 +70,6 @@ function removeAnalyticsListener(callback) {
return callback !== listener;
});
}
exports.removeAnalyticsListener = removeAnalyticsListener;
function dispatchAnalyticsEvent(message) {
// If the window.Flourish object hasn't been created by the customer, they
// can't be listening for analytics events
Expand All @@ -78,7 +79,6 @@ function dispatchAnalyticsEvent(message) {
listener(message);
});
}
exports.dispatchAnalyticsEvent = dispatchAnalyticsEvent;
function initCustomerAnalytics() {
enabled = true;
var events = [
Expand Down Expand Up @@ -111,4 +111,3 @@ function initCustomerAnalytics() {
}, event.use_capture);
});
}
exports.initCustomerAnalytics = initCustomerAnalytics;
4 changes: 2 additions & 2 deletions common/embed/embedding.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function notifyParentWindow(height, opts) {
var message = {
sender: "Flourish",
context: "iframe.resize",
method: "resize",
method: "resize", // backwards compatibility
height: height,
src: embedded_window.location.toString(),
};
Expand Down Expand Up @@ -295,7 +295,7 @@ function createScrolly(iframe, captions) {
step.style.marginLeft = "auto";
step.style.marginRight = "auto";
var caption = document.createElement("div");
caption.innerHTML = dompurify_1.default.sanitize(d);
caption.innerHTML = dompurify_1.default.sanitize(d, { ADD_ATTR: ["target"] });
caption.style.visibility = has_content ? "" : "hidden";
caption.style.display = "inline-block";
caption.style.paddingTop = "1.25em";
Expand Down
16 changes: 8 additions & 8 deletions common/embed/localizations.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
declare namespace _default {
namespace de {
namespace credits {
const _default: string;
let _default: string;
export { _default as default };
}
}
namespace en {
const credits_1: {
let credits_1: {
default: {
text: string;
url: string;
Expand Down Expand Up @@ -159,7 +159,7 @@ declare namespace _default {
export { credits_1 as credits };
}
namespace es {
const credits_2: {
let credits_2: {
default: string;
bar_race: {
text: string;
Expand All @@ -173,7 +173,7 @@ declare namespace _default {
export { credits_2 as credits };
}
namespace fr {
const credits_3: {
let credits_3: {
default: string;
bar_race: {
text: string;
Expand All @@ -187,7 +187,7 @@ declare namespace _default {
export { credits_3 as credits };
}
namespace it {
const credits_4: {
let credits_4: {
default: string;
bar_race: {
text: string;
Expand All @@ -201,7 +201,7 @@ declare namespace _default {
export { credits_4 as credits };
}
namespace mi {
const credits_5: {
let credits_5: {
default: string;
bar_race: {
text: string;
Expand All @@ -215,7 +215,7 @@ declare namespace _default {
export { credits_5 as credits };
}
namespace nl {
const credits_6: {
let credits_6: {
default: string;
bar_race: {
text: string;
Expand All @@ -228,7 +228,7 @@ declare namespace _default {
};
export { credits_6 as credits };
}
const pt: {
let pt: {
default: string;
bar_race: {
text: string;
Expand Down
10 changes: 9 additions & 1 deletion common/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
{
"name": "@flourish/common",
"description": "Common shared utilities",
"scripts": {
"test": "jest"
},
"dependencies": {
"@adobe/css-tools": "^4.3.3",
"@flourish/interpreter": "^8.4.0",
"@flourish/interpreter": "^8.5.0",
"dompurify": "^3.1.4"
},
"devDependencies": {
"@types/jest": "^29.5.12",
"jest": "^29.7.0",
"ts-jest": "^29.1.5"
}
}
2 changes: 1 addition & 1 deletion common/tsconfig.sdk.tsbuildinfo

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions common/utils/columns.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.printDataBinding = exports.parseDataBinding = exports.printColumns = exports.parseColumns = exports.parseRange = exports.printColumn = exports.parseColumn = void 0;
exports.parseColumn = parseColumn;
exports.printColumn = printColumn;
exports.parseRange = parseRange;
exports.parseColumns = parseColumns;
exports.printColumns = printColumns;
exports.parseDataBinding = parseDataBinding;
exports.printDataBinding = printDataBinding;
const MAX_INTEGER = Math.pow(2, 31) - 1;
const MAX_RANGE_LENGTH = Math.pow(2, 15);
// Attempt to parse col_spec as a columns spec;
Expand Down Expand Up @@ -37,7 +43,6 @@ function parseColumn(col_spec, is_optional) {
console.warn("Column index out of range");
return Math.min(col_ix - 1, MAX_INTEGER);
}
exports.parseColumn = parseColumn;
function printColumn(col_ix) {
col_ix += 1;
var col_spec = "";
Expand All @@ -52,7 +57,6 @@ function printColumn(col_ix) {
}
return col_spec;
}
exports.printColumn = printColumn;
function parseRange(col_range) {
var dash_mo = col_range.match(/\s*(?:[-–—:]|\.\.)\s*/);
if (!dash_mo)
Expand All @@ -71,7 +75,6 @@ function parseRange(col_range) {
}
return r;
}
exports.parseRange = parseRange;
function printRange(start, end) {
return printColumn(start) + "-" + printColumn(end);
}
Expand All @@ -92,7 +95,6 @@ function parseColumns(cols_spec) {
}
return indexes;
}
exports.parseColumns = parseColumns;
function splitIntoRanges(indexes) {
if (!indexes.length) {
return [];
Expand Down Expand Up @@ -136,7 +138,6 @@ function printColumns(indexes) {
}
return r.join(",");
}
exports.printColumns = printColumns;
function parseDataBinding(d, data_table_ids) {
var r = {};
if (!(d.type in d)) {
Expand All @@ -158,7 +159,6 @@ function parseDataBinding(d, data_table_ids) {
throw new Error("Unknown data binding type: " + d.type);
return r;
}
exports.parseDataBinding = parseDataBinding;
function printDataBinding(r, data_table_names, print_data_table_name, optional) {
var data_table_name = print_data_table_name ? data_table_names[r.data_table_id] + "::" : "";
if ("column" in r) {
Expand All @@ -172,4 +172,3 @@ function printDataBinding(r, data_table_names, print_data_table_name, optional)
}
throw new Error("Data binding must have .column or .columns");
}
exports.printDataBinding = printDataBinding;
51 changes: 36 additions & 15 deletions common/utils/data.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
export function extractData(data_binding: any, data_by_id: any, column_types_by_id: any, template_data_binding: any): {}[];
export function getColumnTypesForData(data: any): {
type_id: any;
index: number;
output_format_id: any;
}[];
export function getRandomSeededSample(column: any, sample_size: any): any;
export function mulberry32(seed: any): () => number;
export function trimTrailingEmptyRows(data: any): any;
export function dropReturnCharacters(data: any): any;
import "./polyfills";
import { ColumnType, NullableColumnTypesById, DataBinding, DatasetType, TemplateDataBinding, KeyToTemplateDataBinding } from "./types";
export { createInterpreter } from "@flourish/interpreter";
type AugmentedDataBinding = DataBinding & {
key?: string;
template_data_binding?: TemplateDataBinding;
};
type KeyToAugmentedDataBinding = {
[key: string]: AugmentedDataBinding;
};
export type Timestamps = {
last_updated?: Date;
};
export type DatasheetsTimestamps = {
per_data_table: {
[dt_id: string]: Timestamps;
};
};
export declare function extractData(data_binding: KeyToAugmentedDataBinding, data_by_id: {
[data_table_id: string]: string[][] | undefined;
}, column_types_by_id: NullableColumnTypesById, template_data_bindings: KeyToTemplateDataBinding, timestamps: DatasheetsTimestamps): DatasetType;
export declare function getColumnTypesForData(data: string[][]): ColumnType[];
export declare function getRandomSeededSample(column: string[], sample_size: number): string[];
export declare function mulberry32(seed: number): () => number;
export declare function trimTrailingEmptyRows(data: unknown[][]): unknown[][];
export declare function dropReturnCharacters(data: string[][]): string[][];
/**
* Takes an array of arrays (typically tabular data) and rewrites
* it so that:
Expand All @@ -23,8 +39,13 @@ export function dropReturnCharacters(data: any): any;
* @param {any[][]} data
* @returns {string[][]}
*/
export function tidyTable(data: any[][]): string[][];
export function stripCommonFixes(str: any): any;
export function transposeNestedArray(nested_array: any): any[][];
export function getSlicedData(arr: any): any;
export function interpretColumn(arr: any): any;
export declare function tidyTable(data: unknown[][]): string[][];
export declare function stripCommonFixes(str: string): string;
export declare function transposeNestedArray(nested_array: string[][]): string[][];
export declare function getSlicedData(arr: string[]): string[];
export declare function interpretColumn(arr: string[]): any;
export declare function sortDataTables(data_tables: {
name: string;
}[], data_bindings: (string | TemplateDataBinding)[] | undefined): {
name: string;
}[] | undefined;
Loading

0 comments on commit d2db932

Please sign in to comment.