smbls 3.14.19 → 3.14.21
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/CHANGELOG.md +12 -0
- package/dist/smbls.cjs +49 -49
- package/dist/smbls.embed.iife.js +16 -0
- package/dist/smbls.esm.js +31 -31
- package/dist/smbls.iife-string.js +1 -1
- package/dist/smbls.iife.js +49 -49
- package/embed.js +91 -0
- package/package.json +11 -4
package/embed.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Tiny embed-only surface (FT-EMBED-2).
|
|
5
|
+
*
|
|
6
|
+
* Standalone third-party embeds (chat widgets, partner-page surfaces,
|
|
7
|
+
* etc.) ship a tiny script that mounts a Symbols app into a host
|
|
8
|
+
* element. Loading the full `smbls/iife` bundle (~368 KB unminified)
|
|
9
|
+
* for that path forces every embedding partner to download the router,
|
|
10
|
+
* fetch plugin, polyglot, helmet, default config, and full uikit —
|
|
11
|
+
* none of which an embed widget actually uses.
|
|
12
|
+
*
|
|
13
|
+
* This entry re-exports JUST the runtime surface:
|
|
14
|
+
*
|
|
15
|
+
* - element creation (createElement, applyExtends, registerEvent, …)
|
|
16
|
+
* - signal-based state (createStore, createEffect, batch, signal, …)
|
|
17
|
+
* - utils (deepDestringifyFunctions, isObject, …)
|
|
18
|
+
* - design-system core (pushConfig, popConfig, scratch base)
|
|
19
|
+
*
|
|
20
|
+
* No router, no plugins, no DEFAULT_CREATE_OPTIONS pulling in fetch /
|
|
21
|
+
* uikit / initEmotion. Built as an IIFE under the global name
|
|
22
|
+
* `SymbolsEmbed` so a partner can `<script src=".../embed.iife.js">`
|
|
23
|
+
* and call `SymbolsEmbed.mount(rootDef, host)` — single CDN cache hit
|
|
24
|
+
* shared across every page that embeds.
|
|
25
|
+
*
|
|
26
|
+
* `mount(rootDef, host, opts)` is the convenience entry: bypasses the
|
|
27
|
+
* full `create()` pipeline (which expects pages / context / router)
|
|
28
|
+
* and runs `createElement` directly against the supplied host node.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import { create, applyExtends, registerEvent, REGISTRY } from '@symbo.ls/element'
|
|
32
|
+
import { createStore, createEffect, createSignal, batch, getObserver, setObserver } from '@symbo.ls/signal'
|
|
33
|
+
import { pushConfig, popConfig, getActiveConfig, FACTORY } from '@symbo.ls/scratch'
|
|
34
|
+
|
|
35
|
+
// `create` is element's canonical entry — same function the full
|
|
36
|
+
// framework uses. Re-export under both names so embed-side code can
|
|
37
|
+
// stay terminologically aligned with React/Solid embed APIs
|
|
38
|
+
// (`createElement`) while old smbls consumers keep working with the
|
|
39
|
+
// historical `create` name.
|
|
40
|
+
export const createElement = create
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
create,
|
|
44
|
+
applyExtends,
|
|
45
|
+
registerEvent,
|
|
46
|
+
REGISTRY,
|
|
47
|
+
createStore,
|
|
48
|
+
createEffect,
|
|
49
|
+
createSignal,
|
|
50
|
+
batch,
|
|
51
|
+
getObserver,
|
|
52
|
+
setObserver,
|
|
53
|
+
pushConfig,
|
|
54
|
+
popConfig,
|
|
55
|
+
getActiveConfig,
|
|
56
|
+
FACTORY
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Render `rootDef` into `host` and return the resulting element handle.
|
|
61
|
+
*
|
|
62
|
+
* No router, no pages, no default plugins. The host node receives the
|
|
63
|
+
* rendered tree as a child. Reactive props inside `rootDef` (top-level
|
|
64
|
+
* CSS props as functions, `text: (el, s) => …` predicates, etc.) work
|
|
65
|
+
* normally because they go through the same `createElement` path the
|
|
66
|
+
* full framework uses.
|
|
67
|
+
*
|
|
68
|
+
* @param {object} rootDef Component definition (DOMQL object).
|
|
69
|
+
* @param {Element} host DOM node to mount inside.
|
|
70
|
+
* @param {object} [opts]
|
|
71
|
+
* @param {object} [opts.state] Initial state (proxied to createStore).
|
|
72
|
+
* @param {object} [opts.context] Per-app context (no global side-effects).
|
|
73
|
+
* @returns {object} the created element
|
|
74
|
+
*/
|
|
75
|
+
export const mount = (rootDef, host, opts = {}) => {
|
|
76
|
+
if (!rootDef || typeof rootDef !== 'object') {
|
|
77
|
+
throw new Error('[SymbolsEmbed.mount] rootDef must be an object')
|
|
78
|
+
}
|
|
79
|
+
if (!host || typeof host !== 'object' || !host.appendChild) {
|
|
80
|
+
throw new Error('[SymbolsEmbed.mount] host must be a DOM element')
|
|
81
|
+
}
|
|
82
|
+
const state = opts.state ? createStore(opts.state) : undefined
|
|
83
|
+
// element's `create` signature: (definition, parent, key, options).
|
|
84
|
+
// Key defaults to 'Root' to match the existing smbls convention so
|
|
85
|
+
// any reactive state predicate inside the rootDef that walks
|
|
86
|
+
// `el.parent` lands on a node with the expected shape.
|
|
87
|
+
return create(rootDef, host, 'Root', {
|
|
88
|
+
state,
|
|
89
|
+
context: opts.context || {}
|
|
90
|
+
})
|
|
91
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smbls",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.21",
|
|
4
4
|
"license": "CC-BY-NC-4.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/smbls.esm.js",
|
|
@@ -16,6 +16,12 @@
|
|
|
16
16
|
},
|
|
17
17
|
"./iife": "./dist/smbls.iife.js",
|
|
18
18
|
"./iife-string": "./dist/smbls.iife-string.js",
|
|
19
|
+
"./embed": {
|
|
20
|
+
"development": "./embed.js",
|
|
21
|
+
"import": "./embed.js",
|
|
22
|
+
"default": "./embed.js"
|
|
23
|
+
},
|
|
24
|
+
"./embed.iife": "./dist/smbls.embed.iife.js",
|
|
19
25
|
"./package.json": "./package.json"
|
|
20
26
|
},
|
|
21
27
|
"source": "index.js",
|
|
@@ -29,7 +35,8 @@
|
|
|
29
35
|
"build:esm": "node build.mjs esm dist/smbls.esm.js",
|
|
30
36
|
"build:cjs": "node build.mjs cjs dist/smbls.cjs",
|
|
31
37
|
"build:iife": "node build.mjs iife dist/smbls.iife.js && node scripts/build-iife-string.mjs",
|
|
32
|
-
"build": "
|
|
38
|
+
"build:embed": "node build.mjs embed dist/smbls.embed.iife.js --entry embed.js",
|
|
39
|
+
"build": "rimraf dist && npm run build:esm && npm run build:cjs && npm run build:iife && npm run build:embed",
|
|
33
40
|
"prepublishOnly": "npm run build"
|
|
34
41
|
},
|
|
35
42
|
"devDependencies": {
|
|
@@ -38,12 +45,12 @@
|
|
|
38
45
|
"@symbo.ls/element": "^3.14.12",
|
|
39
46
|
"@symbo.ls/state": "^3.14.11",
|
|
40
47
|
"@symbo.ls/css": "^3.14.10",
|
|
41
|
-
"@symbo.ls/utils": "^3.14.
|
|
48
|
+
"@symbo.ls/utils": "^3.14.12",
|
|
42
49
|
"@symbo.ls/wasm": "^3.14.10",
|
|
43
50
|
"@symbo.ls/capsize": "^3.14.8",
|
|
44
51
|
"@symbo.ls/helmet": "^3.14.8",
|
|
45
52
|
"@symbo.ls/inspect": "^3.14.9",
|
|
46
|
-
"@symbo.ls/fetch": "^3.14.
|
|
53
|
+
"@symbo.ls/fetch": "^3.14.9",
|
|
47
54
|
"@symbo.ls/polyglot": "^3.14.8",
|
|
48
55
|
"@symbo.ls/scratch": "^3.14.10",
|
|
49
56
|
"@symbo.ls/shorthand": "^3.14.9",
|